diff --git a/SabreTools.Data.Extensions.Test/MetadataExtensionsTests.cs b/SabreTools.Data.Extensions.Test/MetadataExtensionsTests.cs index 5e13d7b2..16b57fac 100644 --- a/SabreTools.Data.Extensions.Test/MetadataExtensionsTests.cs +++ b/SabreTools.Data.Extensions.Test/MetadataExtensionsTests.cs @@ -96,6 +96,1048 @@ namespace SabreTools.Data.Extensions.Test #endregion + #region PartialEquals + + [Fact] + public void PartialEquals_Disk_Nodumps_True() + { + var self = new Disk + { + Status = ItemStatus.Nodump, + Name = "name", + MD5 = string.Empty, + SHA1 = string.Empty, + }; + var other = new Disk + { + Status = ItemStatus.Nodump, + Name = "name", + MD5 = string.Empty, + SHA1 = string.Empty, + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Disk_Mismatch_False() + { + var self = new Disk + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = string.Empty, + }; + var other = new Disk + { + Name = "name", + MD5 = string.Empty, + SHA1 = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.False(actual); + } + + [Fact] + public void PartialEquals_Disk_PartialMD5_True() + { + var self = new Disk + { + Name = "XXXXXX1", + MD5 = "XXXXXX", + SHA1 = string.Empty, + }; + var other = new Disk + { + Name = "XXXXXX2", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Disk_PartialSHA1_True() + { + var self = new Disk + { + Name = "XXXXXX1", + MD5 = string.Empty, + SHA1 = "XXXXXX", + }; + var other = new Disk + { + Name = "XXXXXX2", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Disk_FullMatch_True() + { + var self = new Disk + { + Name = "XXXXXX1", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + }; + var other = new Disk + { + Name = "XXXXXX2", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Media_Mismatch_False() + { + var self = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = string.Empty, + SHA256 = "XXXXXX", + SpamSum = string.Empty, + }; + var other = new Media + { + Name = "name", + MD5 = string.Empty, + SHA1 = "XXXXXX", + SHA256 = string.Empty, + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.False(actual); + } + + [Fact] + public void PartialEquals_Media_PartialMD5_True() + { + var self = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = string.Empty, + SHA256 = string.Empty, + SpamSum = string.Empty, + }; + var other = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Media_PartialSHA1_True() + { + var self = new Media + { + Name = "name", + MD5 = string.Empty, + SHA1 = "XXXXXX", + SHA256 = string.Empty, + SpamSum = string.Empty, + }; + var other = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Media_PartialSHA256_True() + { + var self = new Media + { + Name = "name", + MD5 = string.Empty, + SHA1 = string.Empty, + SHA256 = "XXXXXX", + SpamSum = string.Empty, + }; + var other = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Media_PartialSpamSum_True() + { + var self = new Media + { + Name = "name", + MD5 = string.Empty, + SHA1 = string.Empty, + SHA256 = string.Empty, + SpamSum = "XXXXXX", + }; + var other = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Media_FullMatch_True() + { + var self = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + var other = new Media + { + Name = "name", + MD5 = "XXXXXX", + SHA1 = "XXXXXX", + SHA256 = "XXXXXX", + SpamSum = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_Nodumps_True() + { + var self = new Rom + { + Status = ItemStatus.Nodump, + Name = "name", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Status = ItemStatus.Nodump, + Name = "name", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_Mismatch_False() + { + var self = new Rom + { + Name = "name", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = "XXXXXX", + }; + var other = new Rom + { + Name = "name", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = string.Empty, + }; + + bool actual = self.PartialEquals(other); + Assert.False(actual); + } + + [Fact] + public void PartialEquals_Rom_NoSelfSize_True() + { + var self = new Rom + { + Name = "XXXXXX1", + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_NoOtherSize_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + var other = new Rom + { + Name = "XXXXXX2", + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialCRC16_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialCRC_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialCRC64_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialMD2_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialMD4_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialMD5_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialRIPEMD128_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialRIPEMD160_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialSHA1_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialSHA256_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialSHA384_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialSHA512_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = string.Empty, + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_PartialSpamSum_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = string.Empty, + [Rom.CRCKey] = string.Empty, + [Rom.CRC64Key] = string.Empty, + [Rom.MD2Key] = string.Empty, + [Rom.MD4Key] = string.Empty, + [Rom.MD5Key] = string.Empty, + [Rom.RIPEMD128Key] = string.Empty, + [Rom.RIPEMD160Key] = string.Empty, + [Rom.SHA1Key] = string.Empty, + [Rom.SHA256Key] = string.Empty, + [Rom.SHA384Key] = string.Empty, + [Rom.SHA512Key] = string.Empty, + [Rom.SpamSumKey] = "XXXXXX", + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + [Fact] + public void PartialEquals_Rom_FullMatch_True() + { + var self = new Rom + { + Name = "XXXXXX1", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + var other = new Rom + { + Name = "XXXXXX2", + Size = 12345, + [Rom.CRC16Key] = "XXXXXX", + [Rom.CRCKey] = "XXXXXX", + [Rom.CRC64Key] = "XXXXXX", + [Rom.MD2Key] = "XXXXXX", + [Rom.MD4Key] = "XXXXXX", + [Rom.MD5Key] = "XXXXXX", + [Rom.RIPEMD128Key] = "XXXXXX", + [Rom.RIPEMD160Key] = "XXXXXX", + [Rom.SHA1Key] = "XXXXXX", + [Rom.SHA256Key] = "XXXXXX", + [Rom.SHA384Key] = "XXXXXX", + [Rom.SHA512Key] = "XXXXXX", + [Rom.SpamSumKey] = "XXXXXX", + }; + + bool actual = self.PartialEquals(other); + Assert.True(actual); + } + + #endregion + #region ConditionalHashEquals [Theory] diff --git a/SabreTools.Data.Extensions/MetadataExtensions.cs b/SabreTools.Data.Extensions/MetadataExtensions.cs index a1329fcd..f37f91f2 100644 --- a/SabreTools.Data.Extensions/MetadataExtensions.cs +++ b/SabreTools.Data.Extensions/MetadataExtensions.cs @@ -64,6 +64,90 @@ namespace SabreTools.Data.Extensions #endregion + #region Equality Checking + + /// + /// Check equality of two Disk objects + /// + public static bool PartialEquals(this Disk self, Disk other) + { + ItemStatus? selfStatus = self.Status; + ItemStatus? otherStatus = other.Status; + + string? selfName = self.Name; + string? otherName = other.Name; + + // If all hashes are empty but they're both nodump and the names match, then they're dupes + if (selfStatus == ItemStatus.Nodump + && otherStatus == ItemStatus.Nodump + && string.Equals(selfName, otherName, StringComparison.OrdinalIgnoreCase) + && !self.HasHashes() + && !other.HasHashes()) + { + return true; + } + + // If we get a partial match + if (self.HashMatch(other)) + return true; + + // All other cases fail + return false; + } + + /// + /// Check equality of two Media objects + /// + public static bool PartialEquals(this Media self, Media other) + { + // If we get a partial match + if (self.HashMatch(other)) + return true; + + // All other cases fail + return false; + } + + /// + /// Check equality of two Rom objects + /// + public static bool PartialEquals(this Rom self, Rom other) + { + ItemStatus? selfStatus = self.Status; + ItemStatus? otherStatus = other.Status; + + string? selfName = self.Name; + string? otherName = other.Name; + + long? selfSize = self.Size; + long? otherSize = other.Size; + + // If all hashes are empty but they're both nodump and the names match, then they're dupes + if (selfStatus == ItemStatus.Nodump + && otherStatus == ItemStatus.Nodump + && string.Equals(selfName, otherName, StringComparison.OrdinalIgnoreCase) + && !self.HasHashes() + && !other.HasHashes()) + { + return true; + } + + // If we have a file that has no known size, rely on the hashes only + if (selfSize is null && self.HashMatch(other)) + return true; + else if (otherSize is null && self.HashMatch(other)) + return true; + + // If we get a partial match + if (selfSize == otherSize && self.HashMatch(other)) + return true; + + // All other cases fail + return false; + } + + #endregion + #region Hash Checking /// diff --git a/SabreTools.Metadata.Test/DictionaryBaseExtensionsTests.cs b/SabreTools.Metadata.Test/DictionaryBaseExtensionsTests.cs deleted file mode 100644 index 8bea60f3..00000000 --- a/SabreTools.Metadata.Test/DictionaryBaseExtensionsTests.cs +++ /dev/null @@ -1,1050 +0,0 @@ -using SabreTools.Data.Models.Metadata; -using Xunit; - -namespace SabreTools.Metadata.Test -{ - public class DictionaryBaseExtensionsTests - { - #region PartialEquals - - [Fact] - public void PartialEquals_Disk_Nodumps_True() - { - var self = new Disk - { - Status = ItemStatus.Nodump, - Name = "name", - MD5 = string.Empty, - SHA1 = string.Empty, - }; - var other = new Disk - { - Status = ItemStatus.Nodump, - Name = "name", - MD5 = string.Empty, - SHA1 = string.Empty, - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Disk_Mismatch_False() - { - var self = new Disk - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = string.Empty, - }; - var other = new Disk - { - Name = "name", - MD5 = string.Empty, - SHA1 = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.False(actual); - } - - [Fact] - public void PartialEquals_Disk_PartialMD5_True() - { - var self = new Disk - { - Name = "XXXXXX1", - MD5 = "XXXXXX", - SHA1 = string.Empty, - }; - var other = new Disk - { - Name = "XXXXXX2", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Disk_PartialSHA1_True() - { - var self = new Disk - { - Name = "XXXXXX1", - MD5 = string.Empty, - SHA1 = "XXXXXX", - }; - var other = new Disk - { - Name = "XXXXXX2", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Disk_FullMatch_True() - { - var self = new Disk - { - Name = "XXXXXX1", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - }; - var other = new Disk - { - Name = "XXXXXX2", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Media_Mismatch_False() - { - var self = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = string.Empty, - SHA256 = "XXXXXX", - SpamSum = string.Empty, - }; - var other = new Media - { - Name = "name", - MD5 = string.Empty, - SHA1 = "XXXXXX", - SHA256 = string.Empty, - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.False(actual); - } - - [Fact] - public void PartialEquals_Media_PartialMD5_True() - { - var self = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = string.Empty, - SHA256 = string.Empty, - SpamSum = string.Empty, - }; - var other = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Media_PartialSHA1_True() - { - var self = new Media - { - Name = "name", - MD5 = string.Empty, - SHA1 = "XXXXXX", - SHA256 = string.Empty, - SpamSum = string.Empty, - }; - var other = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Media_PartialSHA256_True() - { - var self = new Media - { - Name = "name", - MD5 = string.Empty, - SHA1 = string.Empty, - SHA256 = "XXXXXX", - SpamSum = string.Empty, - }; - var other = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Media_PartialSpamSum_True() - { - var self = new Media - { - Name = "name", - MD5 = string.Empty, - SHA1 = string.Empty, - SHA256 = string.Empty, - SpamSum = "XXXXXX", - }; - var other = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Media_FullMatch_True() - { - var self = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - var other = new Media - { - Name = "name", - MD5 = "XXXXXX", - SHA1 = "XXXXXX", - SHA256 = "XXXXXX", - SpamSum = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_Nodumps_True() - { - var self = new Rom - { - Status = ItemStatus.Nodump, - Name = "name", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Status = ItemStatus.Nodump, - Name = "name", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_Mismatch_False() - { - var self = new Rom - { - Name = "name", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = "XXXXXX", - }; - var other = new Rom - { - Name = "name", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = string.Empty, - }; - - bool actual = self.PartialEquals(other); - Assert.False(actual); - } - - [Fact] - public void PartialEquals_Rom_NoSelfSize_True() - { - var self = new Rom - { - Name = "XXXXXX1", - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_NoOtherSize_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - var other = new Rom - { - Name = "XXXXXX2", - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialCRC16_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialCRC_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialCRC64_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialMD2_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialMD4_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialMD5_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialRIPEMD128_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialRIPEMD160_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialSHA1_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialSHA256_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialSHA384_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialSHA512_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = string.Empty, - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_PartialSpamSum_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = string.Empty, - [Rom.CRCKey] = string.Empty, - [Rom.CRC64Key] = string.Empty, - [Rom.MD2Key] = string.Empty, - [Rom.MD4Key] = string.Empty, - [Rom.MD5Key] = string.Empty, - [Rom.RIPEMD128Key] = string.Empty, - [Rom.RIPEMD160Key] = string.Empty, - [Rom.SHA1Key] = string.Empty, - [Rom.SHA256Key] = string.Empty, - [Rom.SHA384Key] = string.Empty, - [Rom.SHA512Key] = string.Empty, - [Rom.SpamSumKey] = "XXXXXX", - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - [Fact] - public void PartialEquals_Rom_FullMatch_True() - { - var self = new Rom - { - Name = "XXXXXX1", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - var other = new Rom - { - Name = "XXXXXX2", - Size = 12345, - [Rom.CRC16Key] = "XXXXXX", - [Rom.CRCKey] = "XXXXXX", - [Rom.CRC64Key] = "XXXXXX", - [Rom.MD2Key] = "XXXXXX", - [Rom.MD4Key] = "XXXXXX", - [Rom.MD5Key] = "XXXXXX", - [Rom.RIPEMD128Key] = "XXXXXX", - [Rom.RIPEMD160Key] = "XXXXXX", - [Rom.SHA1Key] = "XXXXXX", - [Rom.SHA256Key] = "XXXXXX", - [Rom.SHA384Key] = "XXXXXX", - [Rom.SHA512Key] = "XXXXXX", - [Rom.SpamSumKey] = "XXXXXX", - }; - - bool actual = self.PartialEquals(other); - Assert.True(actual); - } - - #endregion - } -} diff --git a/SabreTools.Metadata/DictionaryBaseExtensions.cs b/SabreTools.Metadata/DictionaryBaseExtensions.cs deleted file mode 100644 index d2f419c5..00000000 --- a/SabreTools.Metadata/DictionaryBaseExtensions.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using SabreTools.Data.Extensions; -using SabreTools.Data.Models.Metadata; - -namespace SabreTools.Metadata -{ - public static class DictionaryBaseExtensions - { - #region Equality Checking - - /// - /// Check equality of two Disk objects - /// - public static bool PartialEquals(this Disk self, Disk other) - { - ItemStatus? selfStatus = self.Status; - ItemStatus? otherStatus = other.Status; - - string? selfName = self.Name; - string? otherName = other.Name; - - // If all hashes are empty but they're both nodump and the names match, then they're dupes - if (selfStatus == ItemStatus.Nodump - && otherStatus == ItemStatus.Nodump - && string.Equals(selfName, otherName, StringComparison.OrdinalIgnoreCase) - && !self.HasHashes() - && !other.HasHashes()) - { - return true; - } - - // If we get a partial match - if (self.HashMatch(other)) - return true; - - // All other cases fail - return false; - } - - /// - /// Check equality of two Media objects - /// - public static bool PartialEquals(this Media self, Media other) - { - // If we get a partial match - if (self.HashMatch(other)) - return true; - - // All other cases fail - return false; - } - - /// - /// Check equality of two Rom objects - /// - public static bool PartialEquals(this Rom self, Rom other) - { - ItemStatus? selfStatus = self.Status; - ItemStatus? otherStatus = other.Status; - - string? selfName = self.Name; - string? otherName = other.Name; - - long? selfSize = self.Size; - long? otherSize = other.Size; - - // If all hashes are empty but they're both nodump and the names match, then they're dupes - if (selfStatus == ItemStatus.Nodump - && otherStatus == ItemStatus.Nodump - && string.Equals(selfName, otherName, StringComparison.OrdinalIgnoreCase) - && !self.HasHashes() - && !other.HasHashes()) - { - return true; - } - - // If we have a file that has no known size, rely on the hashes only - if (selfSize is null && self.HashMatch(other)) - return true; - else if (otherSize is null && self.HashMatch(other)) - return true; - - // If we get a partial match - if (selfSize == otherSize && self.HashMatch(other)) - return true; - - // All other cases fail - return false; - } - - #endregion - } -}