mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-06 06:11:45 +00:00
EqualTo has obsoleted itself into the bin
This commit is contained in:
@@ -5,29 +5,19 @@ namespace SabreTools.Metadata.Test
|
||||
{
|
||||
public class DictionaryBaseExtensionsTests
|
||||
{
|
||||
#region EqualTo
|
||||
#region PartialEquals
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_MismatchedTypes_False()
|
||||
public void PartialEquals_Disk_Nodumps_True()
|
||||
{
|
||||
DictionaryBase self = new Disk();
|
||||
DictionaryBase other = new Rom();
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Disk_Nodumps_True()
|
||||
{
|
||||
DictionaryBase self = new Disk
|
||||
var self = new Disk
|
||||
{
|
||||
Status = ItemStatus.Nodump,
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
SHA1 = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Disk
|
||||
var other = new Disk
|
||||
{
|
||||
Status = ItemStatus.Nodump,
|
||||
Name = "name",
|
||||
@@ -35,94 +25,94 @@ namespace SabreTools.Metadata.Test
|
||||
SHA1 = string.Empty,
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Disk_Mismatch_False()
|
||||
public void PartialEquals_Disk_Mismatch_False()
|
||||
{
|
||||
DictionaryBase self = new Disk
|
||||
var self = new Disk
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Disk
|
||||
var other = new Disk
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Disk_PartialMD5_True()
|
||||
public void PartialEquals_Disk_PartialMD5_True()
|
||||
{
|
||||
DictionaryBase self = new Disk
|
||||
var self = new Disk
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Disk
|
||||
var other = new Disk
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Disk_PartialSHA1_True()
|
||||
public void PartialEquals_Disk_PartialSHA1_True()
|
||||
{
|
||||
DictionaryBase self = new Disk
|
||||
var self = new Disk
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
MD5 = string.Empty,
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Disk
|
||||
var other = new Disk
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Disk_FullMatch_True()
|
||||
public void PartialEquals_Disk_FullMatch_True()
|
||||
{
|
||||
DictionaryBase self = new Disk
|
||||
var self = new Disk
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Disk
|
||||
var other = new Disk
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
MD5 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_Mismatch_False()
|
||||
public void PartialEquals_Media_Mismatch_False()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -130,7 +120,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = "XXXXXX",
|
||||
SpamSum = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
@@ -139,14 +129,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_PartialMD5_True()
|
||||
public void PartialEquals_Media_PartialMD5_True()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -154,7 +144,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = string.Empty,
|
||||
SpamSum = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -163,14 +153,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_PartialSHA1_True()
|
||||
public void PartialEquals_Media_PartialSHA1_True()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
@@ -178,7 +168,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = string.Empty,
|
||||
SpamSum = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -187,14 +177,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_PartialSHA256_True()
|
||||
public void PartialEquals_Media_PartialSHA256_True()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
@@ -202,7 +192,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = "XXXXXX",
|
||||
SpamSum = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -211,14 +201,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_PartialSpamSum_True()
|
||||
public void PartialEquals_Media_PartialSpamSum_True()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = string.Empty,
|
||||
@@ -226,7 +216,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = string.Empty,
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -235,14 +225,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Media_FullMatch_True()
|
||||
public void PartialEquals_Media_FullMatch_True()
|
||||
{
|
||||
DictionaryBase self = new Media
|
||||
var self = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -250,7 +240,7 @@ namespace SabreTools.Metadata.Test
|
||||
SHA256 = "XXXXXX",
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Media
|
||||
var other = new Media
|
||||
{
|
||||
Name = "name",
|
||||
MD5 = "XXXXXX",
|
||||
@@ -259,14 +249,14 @@ namespace SabreTools.Metadata.Test
|
||||
SpamSum = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_Nodumps_True()
|
||||
public void PartialEquals_Rom_Nodumps_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Status = ItemStatus.Nodump,
|
||||
Name = "name",
|
||||
@@ -285,7 +275,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Status = ItemStatus.Nodump,
|
||||
Name = "name",
|
||||
@@ -305,14 +295,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_Mismatch_False()
|
||||
public void PartialEquals_Rom_Mismatch_False()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "name",
|
||||
Size = 12345,
|
||||
@@ -330,7 +320,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "name",
|
||||
Size = 12345,
|
||||
@@ -349,14 +339,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_NoSelfSize_True()
|
||||
public void PartialEquals_Rom_NoSelfSize_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
[Rom.CRC16Key] = "XXXXXX",
|
||||
@@ -373,7 +363,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = "XXXXXX",
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -392,14 +382,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_NoOtherSize_True()
|
||||
public void PartialEquals_Rom_NoOtherSize_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -417,7 +407,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = "XXXXXX",
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
[Rom.CRC16Key] = "XXXXXX",
|
||||
@@ -435,14 +425,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialCRC16_True()
|
||||
public void PartialEquals_Rom_PartialCRC16_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -460,7 +450,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -479,14 +469,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialCRC_True()
|
||||
public void PartialEquals_Rom_PartialCRC_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -504,7 +494,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -523,14 +513,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialCRC64_True()
|
||||
public void PartialEquals_Rom_PartialCRC64_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -548,7 +538,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -567,14 +557,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialMD2_True()
|
||||
public void PartialEquals_Rom_PartialMD2_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -592,7 +582,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -611,14 +601,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialMD4_True()
|
||||
public void PartialEquals_Rom_PartialMD4_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -636,7 +626,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -655,14 +645,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialMD5_True()
|
||||
public void PartialEquals_Rom_PartialMD5_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -680,7 +670,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -699,14 +689,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialRIPEMD128_True()
|
||||
public void PartialEquals_Rom_PartialRIPEMD128_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -724,7 +714,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -743,14 +733,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialRIPEMD160_True()
|
||||
public void PartialEquals_Rom_PartialRIPEMD160_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -768,7 +758,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -787,14 +777,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialSHA1_True()
|
||||
public void PartialEquals_Rom_PartialSHA1_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -812,7 +802,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -831,14 +821,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialSHA256_True()
|
||||
public void PartialEquals_Rom_PartialSHA256_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -856,7 +846,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -875,14 +865,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialSHA384_True()
|
||||
public void PartialEquals_Rom_PartialSHA384_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -900,7 +890,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -919,14 +909,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialSHA512_True()
|
||||
public void PartialEquals_Rom_PartialSHA512_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -944,7 +934,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = "XXXXXX",
|
||||
[Rom.SpamSumKey] = string.Empty,
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -963,14 +953,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_PartialSpamSum_True()
|
||||
public void PartialEquals_Rom_PartialSpamSum_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -988,7 +978,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = string.Empty,
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -1007,14 +997,14 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Rom_FullMatch_True()
|
||||
public void PartialEquals_Rom_FullMatch_True()
|
||||
{
|
||||
DictionaryBase self = new Rom
|
||||
var self = new Rom
|
||||
{
|
||||
Name = "XXXXXX1",
|
||||
Size = 12345,
|
||||
@@ -1032,7 +1022,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SHA512Key] = "XXXXXX",
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
DictionaryBase other = new Rom
|
||||
var other = new Rom
|
||||
{
|
||||
Name = "XXXXXX2",
|
||||
Size = 12345,
|
||||
@@ -1051,61 +1041,7 @@ namespace SabreTools.Metadata.Test
|
||||
[Rom.SpamSumKey] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Other_BothEmpty_True()
|
||||
{
|
||||
DictionaryBase self = new Sample();
|
||||
DictionaryBase other = new Sample();
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Other_MismatchedCount_False()
|
||||
{
|
||||
DictionaryBase self = new Sample { ["KEY1"] = "XXXXXX", };
|
||||
DictionaryBase other = new Sample
|
||||
{
|
||||
["KEY1"] = "XXXXXX",
|
||||
["KEY2"] = "XXXXXX",
|
||||
};
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Other_MismatchedKeys_False()
|
||||
{
|
||||
DictionaryBase self = new Sample { ["KEY1"] = "XXXXXX", };
|
||||
DictionaryBase other = new Sample { ["KEY2"] = "XXXXXX", };
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Other_MismatchedValues_False()
|
||||
{
|
||||
DictionaryBase self = new Sample { ["KEY1"] = "XXXXXX", };
|
||||
DictionaryBase other = new Sample { ["KEY1"] = "ZZZZZZ", };
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTo_Other_Matching_True()
|
||||
{
|
||||
DictionaryBase self = new Sample { ["KEY1"] = "XXXXXX", };
|
||||
DictionaryBase other = new Sample { ["KEY1"] = "XXXXXX", };
|
||||
|
||||
bool actual = self.EqualTo(other);
|
||||
bool actual = self.PartialEquals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SabreTools.Metadata.Test
|
||||
return false;
|
||||
|
||||
// Compare internal models
|
||||
return _internal.EqualTo(otherItem._internal);
|
||||
return _internal.Equals(otherItem._internal);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Metadata.Test
|
||||
return false;
|
||||
|
||||
// Compare internal models
|
||||
return _internal.EqualTo(otherItem._internal);
|
||||
return _internal.Equals(otherItem._internal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools.Metadata.Test
|
||||
return false;
|
||||
|
||||
// Compare internal models
|
||||
return _internal.EqualTo(otherItem._internal);
|
||||
return _internal[TestDictionaryBase.NameKey] == otherItem._internal[TestDictionaryBase.NameKey];
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -89,7 +89,7 @@ namespace SabreTools.Metadata.Test
|
||||
return false;
|
||||
|
||||
// Compare internal models
|
||||
return _internal.EqualTo(otherItem._internal);
|
||||
return _internal[TestDictionaryBase.NameKey] == otherItem._internal[TestDictionaryBase.NameKey];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -97,66 +97,6 @@ namespace SabreTools.Metadata.Test
|
||||
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
[Fact]
|
||||
public void Equals_NullOther_False()
|
||||
{
|
||||
ModelBackedItem self = new TestModelBackedItem();
|
||||
ModelBackedItem? other = null;
|
||||
|
||||
bool actual = self.Equals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_MismatchedType_False()
|
||||
{
|
||||
ModelBackedItem self = new TestModelBackedItem();
|
||||
ModelBackedItem? other = new TestModelAltBackedItem();
|
||||
|
||||
bool actual = self.Equals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_MismatchedTypeAlt_False()
|
||||
{
|
||||
ModelBackedItem self = new TestModelAltBackedItem();
|
||||
ModelBackedItem? other = new TestModelBackedItem();
|
||||
|
||||
bool actual = self.Equals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_DifferentModels_False()
|
||||
{
|
||||
ModelBackedItem<TestDictionaryBase> self = new TestModelBackedItem();
|
||||
self.Write(TestDictionaryBase.NameKey, "self");
|
||||
|
||||
ModelBackedItem<TestDictionaryBase>? other = new TestModelBackedItem();
|
||||
other.Write(TestDictionaryBase.NameKey, "other");
|
||||
|
||||
bool actual = self.Equals(other);
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equals_EqualModels_True()
|
||||
{
|
||||
ModelBackedItem<TestDictionaryBase> self = new TestModelBackedItem();
|
||||
self.Write(TestDictionaryBase.NameKey, "name");
|
||||
|
||||
ModelBackedItem<TestDictionaryBase>? other = new TestModelBackedItem();
|
||||
other.Write(TestDictionaryBase.NameKey, "name");
|
||||
|
||||
bool actual = self.Equals(other);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Remove
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Data.Models.Metadata;
|
||||
|
||||
@@ -10,282 +8,6 @@ namespace SabreTools.Metadata
|
||||
{
|
||||
#region Equality Checking
|
||||
|
||||
/// <summary>
|
||||
/// Check equality of two DictionaryBase objects
|
||||
/// </summary>
|
||||
/// TODO: Fix equality checking with case sensitivity of string properties
|
||||
public static bool EqualTo(this DictionaryBase self, DictionaryBase other)
|
||||
{
|
||||
// Check types first
|
||||
if (self.GetType() != other.GetType())
|
||||
return false;
|
||||
|
||||
// Check based on the item type
|
||||
#if NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
return (self, other) switch
|
||||
{
|
||||
(Adjuster selfAdjuster, Adjuster otherAdjuster) => selfAdjuster.Equals(otherAdjuster),
|
||||
(Analog selfAnalog, Analog otherAnalog) => selfAnalog.Equals(otherAnalog),
|
||||
(Archive selfArchive, Archive otherArchive) => selfArchive.Equals(otherArchive),
|
||||
(BiosSet selfBiosSet, BiosSet otherBiosSet) => selfBiosSet.Equals(otherBiosSet),
|
||||
(Chip selfChip, Chip otherChip) => selfChip.Equals(otherChip),
|
||||
(Condition selfCondition, Condition otherCondition) => selfCondition.Equals(otherCondition),
|
||||
(Configuration selfConfiguration, Configuration otherConfiguration) => selfConfiguration.Equals(otherConfiguration),
|
||||
(ConfLocation selfConfLocation, ConfLocation otherConfLocation) => selfConfLocation.Equals(otherConfLocation),
|
||||
(ConfSetting selfConfSetting, ConfSetting otherConfSetting) => selfConfSetting.Equals(otherConfSetting),
|
||||
(Control selfControl, Control otherControl) => selfControl.Equals(otherControl),
|
||||
(DataArea selfDataArea, DataArea otherDataArea) => selfDataArea.Equals(otherDataArea),
|
||||
(Device selfDevice, Device otherDevice) => selfDevice.Equals(otherDevice),
|
||||
(DipLocation selfDipLocation, DipLocation otherDipLocation) => selfDipLocation.Equals(otherDipLocation),
|
||||
(DipSwitch selfDipSwitch, DipSwitch otherDipSwitch) => selfDipSwitch.Equals(otherDipSwitch),
|
||||
(DipValue selfDipValue, DipValue otherDipValue) => selfDipValue.Equals(otherDipValue),
|
||||
(Disk selfDisk, Disk otherDisk) => PartialEquals(selfDisk, otherDisk),
|
||||
(DiskArea selfDiskArea, DiskArea otherDiskArea) => selfDiskArea.Equals(otherDiskArea),
|
||||
(Display selfDisplay, Display otherDisplay) => selfDisplay.Equals(otherDisplay),
|
||||
(Driver selfDriver, Driver otherDriver) => selfDriver.Equals(otherDriver),
|
||||
(Dump selfDump, Dump otherDump) => selfDump.Equals(otherDump),
|
||||
(Feature selfFeature, Feature otherFeature) => selfFeature.Equals(otherFeature),
|
||||
(Header selfHeader, Header otherHeader) => selfHeader.Equals(otherHeader),
|
||||
(Info selfInfo, Info otherInfo) => selfInfo.Equals(otherInfo),
|
||||
(Input selfInput, Input otherInput) => selfInput.Equals(otherInput),
|
||||
(Instance selfInstance, Instance otherInstance) => selfInstance.Equals(otherInstance),
|
||||
(Machine selfMachine, Machine otherMachine) => Equals(selfMachine, otherMachine),
|
||||
(Media selfMedia, Media otherMedia) => PartialEquals(selfMedia, otherMedia),
|
||||
(Original selfOriginal, Original otherOriginal) => selfOriginal.Equals(otherOriginal),
|
||||
(Part selfPart, Part otherPart) => selfPart.Equals(otherPart),
|
||||
(Port selfPort, Port otherPort) => selfPort.Equals(otherPort),
|
||||
(RamOption selfRamOption, RamOption otherRamOption) => selfRamOption.Equals(otherRamOption),
|
||||
(Release selfRelease, Release otherRelease) => selfRelease.Equals(otherRelease),
|
||||
(ReleaseDetails selfReleaseDetails, ReleaseDetails otherReleaseDetails) => selfReleaseDetails.Equals(otherReleaseDetails),
|
||||
(Rom selfRom, Rom otherRom) => PartialEquals(selfRom, otherRom),
|
||||
(Serials selfSerials, Serials otherSerials) => selfSerials.Equals(otherSerials),
|
||||
(SharedFeat selfSharedFeat, SharedFeat otherSharedFeat) => selfSharedFeat.Equals(otherSharedFeat),
|
||||
(Slot selfSlot, Slot otherSlot) => selfSlot.Equals(otherSlot),
|
||||
(SlotOption selfSlotOption, SlotOption otherSlotOption) => selfSlotOption.Equals(otherSlotOption),
|
||||
(SoftwareList selfSoftwareList, SoftwareList otherSoftwareList) => selfSoftwareList.Equals(otherSoftwareList),
|
||||
(Sound selfSound, Sound otherSound) => selfSound.Equals(otherSound),
|
||||
(SourceDetails selfSourceDetails, SourceDetails otherSourceDetails) => selfSourceDetails.Equals(otherSourceDetails),
|
||||
(Video selfVideo, Video otherVideo) => Equals(selfVideo, otherVideo),
|
||||
_ => self.EqualsImpl(other),
|
||||
};
|
||||
#else
|
||||
if (self is Adjuster selfAdjuster && other is Adjuster otherAdjuster)
|
||||
return selfAdjuster.Equals(otherAdjuster);
|
||||
else if (self is Analog selfAnalog && other is Analog otherAnalog)
|
||||
return selfAnalog.Equals(otherAnalog);
|
||||
else if (self is Archive selfArchive && other is Archive otherArchive)
|
||||
return selfArchive.Equals(otherArchive);
|
||||
else if (self is BiosSet selfBiosSet && other is BiosSet otherBiosSet)
|
||||
return selfBiosSet.Equals(otherBiosSet);
|
||||
else if (self is Chip selfChip && other is Chip otherChip)
|
||||
return selfChip.Equals(otherChip);
|
||||
else if (self is Condition selfCondition && other is Condition otherCondition)
|
||||
return selfCondition.Equals(otherCondition);
|
||||
else if (self is Configuration selfConfiguration && other is Configuration otherConfiguration)
|
||||
return selfConfiguration.Equals(otherConfiguration);
|
||||
else if (self is ConfLocation selfConfLocation && other is ConfLocation otherConfLocation)
|
||||
return selfConfLocation.Equals(otherConfLocation);
|
||||
else if (self is ConfSetting selfConfSetting && other is ConfSetting otherConfSetting)
|
||||
return selfConfSetting.Equals(otherConfSetting);
|
||||
else if (self is Control selfControl && other is Control otherControl)
|
||||
return selfControl.Equals(otherControl);
|
||||
else if (self is DataArea selfDataArea && other is DataArea otherDataArea)
|
||||
return selfDataArea.Equals(otherDataArea);
|
||||
else if (self is Device selfDevice && other is Device otherDevice)
|
||||
return selfDevice.Equals(otherDevice);
|
||||
else if (self is DipLocation selfDipLocation && other is DipLocation otherDipLocation)
|
||||
return selfDipLocation.Equals(otherDipLocation);
|
||||
else if (self is DipSwitch selfDipSwitch && other is DipSwitch otherDipSwitch)
|
||||
return selfDipSwitch.Equals(otherDipSwitch);
|
||||
else if (self is DipValue selfDipValue && other is DipValue otherDipValue)
|
||||
return selfDipValue.Equals(otherDipValue);
|
||||
else if (self is Disk selfDisk && other is Disk otherDisk)
|
||||
return PartialEquals(selfDisk, otherDisk);
|
||||
else if (self is DiskArea selfDiskArea && other is DiskArea otherDiskArea)
|
||||
return selfDiskArea.Equals(otherDiskArea);
|
||||
else if (self is Display selfDisplay && other is Display otherDisplay)
|
||||
return selfDisplay.Equals(otherDisplay);
|
||||
else if (self is Driver selfDriver && other is Driver otherDriver)
|
||||
return selfDriver.Equals(otherDriver);
|
||||
else if (self is Dump selfDump && other is Dump otherDump)
|
||||
return selfDump.Equals(otherDump);
|
||||
else if (self is Feature selfFeature && other is Feature otherFeature)
|
||||
return selfFeature.Equals(otherFeature);
|
||||
else if (self is Header selfHeader && other is Header otherHeader)
|
||||
return selfHeader.Equals(otherHeader);
|
||||
else if (self is Info selfInfo && other is Info otherInfo)
|
||||
return selfInfo.Equals(otherInfo);
|
||||
else if (self is Input selfInput && other is Input otherInput)
|
||||
return selfInput.Equals(otherInput);
|
||||
else if (self is Instance selfInstance && other is Instance otherInstance)
|
||||
return selfInstance.Equals(otherInstance);
|
||||
else if (self is Machine selfMachine && other is Machine otherMachine)
|
||||
return Equals(selfMachine, otherMachine);
|
||||
else if (self is Media selfMedia && other is Media otherMedia)
|
||||
return PartialEquals(selfMedia, otherMedia);
|
||||
else if (self is Original selfOriginal && other is Original otherOriginal)
|
||||
return selfOriginal.Equals(otherOriginal);
|
||||
else if (self is Part selfPart && other is Part otherPart)
|
||||
return selfPart.Equals(otherPart);
|
||||
else if (self is Port selfPort && other is Port otherPort)
|
||||
return selfPort.Equals(otherPort);
|
||||
else if (self is RamOption selfRamOption && other is RamOption otherRamOption)
|
||||
return selfRamOption.Equals(otherRamOption);
|
||||
else if (self is Release selfRelease && other is Release otherRelease)
|
||||
return selfRelease.Equals(otherRelease);
|
||||
else if (self is ReleaseDetails selfReleaseDetails && other is ReleaseDetails otherReleaseDetails)
|
||||
return selfReleaseDetails.Equals(otherReleaseDetails);
|
||||
else if (self is Rom selfRom && other is Rom otherRom)
|
||||
return PartialEquals(selfRom, otherRom);
|
||||
else if (self is Serials selfSerials && other is Serials otherSerials)
|
||||
return selfSerials.Equals(otherSerials);
|
||||
else if (self is SharedFeat selfSharedFeat && other is SharedFeat otherSharedFeat)
|
||||
return selfSharedFeat.Equals(otherSharedFeat);
|
||||
else if (self is Slot selfSlot && other is Slot otherSlot)
|
||||
return selfSlot.Equals(otherSlot);
|
||||
else if (self is SlotOption selfSlotOption && other is SlotOption otherSlotOption)
|
||||
return selfSlotOption.Equals(otherSlotOption);
|
||||
else if (self is SoftwareList selfSoftwareList && other is SoftwareList otherSoftwareList)
|
||||
return selfSoftwareList.Equals(otherSoftwareList);
|
||||
else if (self is Sound selfSound && other is Sound otherSound)
|
||||
return selfSound.Equals(otherSound);
|
||||
else if (self is SourceDetails selfSourceDetails && other is SourceDetails otherSourceDetails)
|
||||
return selfSourceDetails.Equals(otherSourceDetails);
|
||||
else if (self is Video selfVideo && other is Video otherVideo)
|
||||
return selfVideo.Equals(otherVideo);
|
||||
else
|
||||
return EqualsImpl(self, other);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check equality of two DictionaryBase objects
|
||||
/// </summary>
|
||||
/// TODO: Fix equality checking with case sensitivity of string properties
|
||||
private static bool EqualsImpl(this DictionaryBase self, DictionaryBase other)
|
||||
{
|
||||
// If the number of key-value pairs doesn't match, they can't match
|
||||
if (self.Count != other.Count)
|
||||
return false;
|
||||
|
||||
// If any keys are missing on either side, they can't match
|
||||
var selfKeys = new HashSet<string>(self.Keys);
|
||||
var otherKeys = new HashSet<string>(other.Keys);
|
||||
if (!selfKeys.SetEquals(otherKeys))
|
||||
return false;
|
||||
|
||||
// Check all pairs to see if they're equal
|
||||
foreach (var kvp in self)
|
||||
{
|
||||
#if NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
switch (kvp.Value, other[kvp.Key])
|
||||
{
|
||||
case (string selfString, string otherString):
|
||||
if (!string.Equals(selfString, otherString, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case (ModelBackedItem selfMbi, ModelBackedItem otherMbi):
|
||||
if (!selfMbi.Equals(otherMbi))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case (DictionaryBase selfDb, DictionaryBase otherDb):
|
||||
if (!selfDb.Equals(otherDb))
|
||||
return false;
|
||||
break;
|
||||
|
||||
// TODO: Make this case-insensitive
|
||||
case (string[] selfStrArr, string[] otherStrArr):
|
||||
if (selfStrArr.Length != otherStrArr.Length)
|
||||
return false;
|
||||
if (selfStrArr.Except(otherStrArr).Any())
|
||||
return false;
|
||||
if (otherStrArr.Except(selfStrArr).Any())
|
||||
return false;
|
||||
break;
|
||||
|
||||
// TODO: Fix the logic here for real equality
|
||||
case (DictionaryBase[] selfDbArr, DictionaryBase[] otherDbArr):
|
||||
if (selfDbArr.Length != otherDbArr.Length)
|
||||
return false;
|
||||
if (selfDbArr.Except(otherDbArr).Any())
|
||||
return false;
|
||||
if (otherDbArr.Except(selfDbArr).Any())
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Handle cases where a null is involved
|
||||
if (kvp.Value is null && other[kvp.Key] is null)
|
||||
return true;
|
||||
else if (kvp.Value is null && other[kvp.Key] is not null)
|
||||
return false;
|
||||
else if (kvp.Value is not null && other[kvp.Key] is null)
|
||||
return false;
|
||||
|
||||
// Try to rely on type hashes
|
||||
else if (kvp.Value!.GetHashCode() != other[kvp.Key]!.GetHashCode())
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (kvp.Value is string selfString && other[kvp.Key] is string otherString)
|
||||
{
|
||||
if (!string.Equals(selfString, otherString, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
}
|
||||
else if (kvp.Value is ModelBackedItem selfMbi && other[kvp.Key] is ModelBackedItem otherMbi)
|
||||
{
|
||||
if (!selfMbi.Equals(otherMbi))
|
||||
return false;
|
||||
}
|
||||
else if (kvp.Value is DictionaryBase selfDb && other[kvp.Key] is DictionaryBase otherDb)
|
||||
{
|
||||
if (!selfDb.Equals(otherDb))
|
||||
return false;
|
||||
}
|
||||
else if (kvp.Value is string[] selfStrArr && other[kvp.Key] is string[] otherStrArr)
|
||||
{
|
||||
// TODO: Make this case-insensitive
|
||||
if (selfStrArr.Length != otherStrArr.Length)
|
||||
return false;
|
||||
if (selfStrArr.Except(otherStrArr).Any())
|
||||
return false;
|
||||
if (otherStrArr.Except(selfStrArr).Any())
|
||||
return false;
|
||||
}
|
||||
else if (kvp.Value is DictionaryBase[] selfDbArr && other[kvp.Key] is DictionaryBase[] otherDbArr)
|
||||
{
|
||||
// TODO: Fix the logic here for real equality
|
||||
if (selfDbArr.Length != otherDbArr.Length)
|
||||
return false;
|
||||
if (selfDbArr.Except(otherDbArr).Any())
|
||||
return false;
|
||||
if (otherDbArr.Except(selfDbArr).Any())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle cases where a null is involved
|
||||
if (kvp.Value is null && other[kvp.Key] is null)
|
||||
return true;
|
||||
else if (kvp.Value is null && other[kvp.Key] is not null)
|
||||
return false;
|
||||
else if (kvp.Value is not null && other[kvp.Key] is null)
|
||||
return false;
|
||||
|
||||
// Try to rely on type hashes
|
||||
else if (kvp.Value!.GetHashCode() != other[kvp.Key]!.GetHashCode())
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check equality of two Disk objects
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user