diff --git a/ATL.unit-test/Misc/LyricsSortTest.cs b/ATL.unit-test/Misc/LyricsSortTest.cs index 8fbe4025..7f118ac0 100644 --- a/ATL.unit-test/Misc/LyricsSortTest.cs +++ b/ATL.unit-test/Misc/LyricsSortTest.cs @@ -9,13 +9,15 @@ public class LyricsSortTest private LyricsInfo.LyricsPhrase lyrics1 = new(1000, "AAA"); private LyricsInfo.LyricsPhrase lyrics1b = new(1000, "AAA"); private LyricsInfo.LyricsPhrase lyrics2 = new(2000, "ZZZ"); - + private LyricsInfo.LyricsPhrase lyrics3 = null; [TestMethod] public void LyricsSort_Equality() { Assert.IsTrue(lyrics1 != lyrics2); + Assert.IsTrue(lyrics1 != null); Assert.IsTrue(lyrics1 == lyrics1b); + Assert.IsTrue(lyrics3 == null); Assert.IsTrue(lyrics1 >= lyrics1b); Assert.IsTrue(lyrics1 <= lyrics1b); Assert.IsTrue(lyrics1 == new LyricsInfo.LyricsPhrase(lyrics1)); diff --git a/ATL/Entities/LyricsInfo.cs b/ATL/Entities/LyricsInfo.cs index 06c4bbdb..8e9eb2d0 100644 --- a/ATL/Entities/LyricsInfo.cs +++ b/ATL/Entities/LyricsInfo.cs @@ -154,7 +154,14 @@ public override bool Equals(object obj) /// The first LyricsPhrase object /// The second LyricsPhrase object /// True if a == b, else false - public static bool operator ==(LyricsPhrase a, LyricsPhrase b) => !ReferenceEquals(a, null) && a.Equals(b); + public static bool operator ==(LyricsPhrase a, LyricsPhrase b) + { + if (ReferenceEquals(a, null) && ReferenceEquals(b, null)) + { + return true; + } + return !ReferenceEquals(a, null) && a.Equals(b); + } /// /// Compares two LyricsPhrase objects by not-equals @@ -162,7 +169,14 @@ public override bool Equals(object obj) /// The first LyricsPhrase object /// The second LyricsPhrase object /// True if a != b, else false - public static bool operator !=(LyricsPhrase a, LyricsPhrase b) => !ReferenceEquals(a, null) && !a.Equals(b); + public static bool operator !=(LyricsPhrase a, LyricsPhrase b) + { + if ((!ReferenceEquals(a, null) && ReferenceEquals(b, null)) || (ReferenceEquals(a, null) && !ReferenceEquals(b, null))) + { + return true; + } + return !ReferenceEquals(a, null) && !a.Equals(b); + } /// /// Compares two LyricsPhrase objects by inferior