mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-05 22:01:33 +00:00
2166 lines
76 KiB
C#
2166 lines
76 KiB
C#
using SabreTools.Data.Models.Metadata;
|
|
using SabreTools.Hashing;
|
|
using Xunit;
|
|
|
|
namespace SabreTools.Data.Extensions.Test
|
|
{
|
|
public class MetadataExtensionsTests
|
|
{
|
|
#region ConvertToRom
|
|
|
|
[Fact]
|
|
public void ConvertToRom_Null_Null()
|
|
{
|
|
DictionaryBase? self = null;
|
|
Rom? actual = self.ConvertToRom();
|
|
Assert.Null(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertToRom_EmptyDisk_EmptyRom()
|
|
{
|
|
DictionaryBase? self = new Disk();
|
|
Rom? actual = self.ConvertToRom();
|
|
|
|
Assert.NotNull(actual);
|
|
Assert.Equal(8, actual.Count);
|
|
Assert.Equal(ItemType.Rom, actual["_type"]);
|
|
Assert.Null(actual[Rom.NameKey]);
|
|
Assert.Null(actual[Rom.MergeKey]);
|
|
Assert.Null(actual[Rom.RegionKey]);
|
|
Assert.Null(actual[Rom.StatusKey]);
|
|
Assert.Null(actual[Rom.OptionalKey]);
|
|
Assert.Null(actual[Rom.MD5Key]);
|
|
Assert.Null(actual[Rom.SHA1Key]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertToRom_FilledDisk_FilledRom()
|
|
{
|
|
DictionaryBase? self = new Disk
|
|
{
|
|
[Disk.NameKey] = "XXXXXX",
|
|
[Disk.MergeKey] = "XXXXXX",
|
|
[Disk.RegionKey] = "XXXXXX",
|
|
[Disk.StatusKey] = "XXXXXX",
|
|
[Disk.OptionalKey] = "XXXXXX",
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
Rom? actual = self.ConvertToRom();
|
|
|
|
Assert.NotNull(actual);
|
|
Assert.Equal(8, actual.Count);
|
|
Assert.Equal(ItemType.Rom, actual["_type"]);
|
|
Assert.Equal("XXXXXX.chd", actual[Rom.NameKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.MergeKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.RegionKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.StatusKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.OptionalKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.MD5Key]);
|
|
Assert.Equal("XXXXXX", actual[Rom.SHA1Key]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertToRom_EmptyMedia_EmptyRom()
|
|
{
|
|
DictionaryBase? self = new Media();
|
|
Rom? actual = self.ConvertToRom();
|
|
|
|
Assert.NotNull(actual);
|
|
Assert.Equal(6, actual.Count);
|
|
Assert.Equal(ItemType.Rom, actual["_type"]);
|
|
Assert.Null(actual[Rom.NameKey]);
|
|
Assert.Null(actual[Rom.MD5Key]);
|
|
Assert.Null(actual[Rom.SHA1Key]);
|
|
Assert.Null(actual[Rom.SHA256Key]);
|
|
Assert.Null(actual[Rom.SpamSumKey]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertToRom_FilledMedia_FilledRom()
|
|
{
|
|
DictionaryBase? self = new Media
|
|
{
|
|
[Media.NameKey] = "XXXXXX",
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
Rom? actual = self.ConvertToRom();
|
|
|
|
Assert.NotNull(actual);
|
|
Assert.Equal(6, actual.Count);
|
|
Assert.Equal(ItemType.Rom, actual["_type"]);
|
|
Assert.Equal("XXXXXX.aaruf", actual[Rom.NameKey]);
|
|
Assert.Equal("XXXXXX", actual[Rom.MD5Key]);
|
|
Assert.Equal("XXXXXX", actual[Rom.SHA1Key]);
|
|
Assert.Equal("XXXXXX", actual[Rom.SHA256Key]);
|
|
Assert.Equal("XXXXXX", actual[Rom.SpamSumKey]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertToRom_Other_Null()
|
|
{
|
|
DictionaryBase? self = new Sample();
|
|
Rom? actual = self.ConvertToRom();
|
|
Assert.Null(actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ConditionalHashEquals
|
|
|
|
[Theory]
|
|
[InlineData(null, null, true)]
|
|
[InlineData(new byte[0], new byte[0], true)]
|
|
[InlineData(new byte[] { 0x01 }, new byte[0], true)]
|
|
[InlineData(new byte[0], new byte[] { 0x01 }, true)]
|
|
[InlineData(new byte[] { 0x01 }, new byte[] { 0x01 }, true)]
|
|
[InlineData(new byte[] { 0x01, 0x02 }, new byte[] { 0x01 }, false)]
|
|
[InlineData(new byte[] { 0x01 }, new byte[] { 0x01, 0x02 }, false)]
|
|
[InlineData(new byte[] { 0x01, 0x02 }, new byte[] { 0x02, 0x01 }, false)]
|
|
public void ConditionalHashEquals_Array(byte[]? firstHash, byte[]? secondHash, bool expected)
|
|
{
|
|
bool actual = MetadataExtensions.ConditionalHashEquals(firstHash, secondHash);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null, true)]
|
|
[InlineData("", "", true)]
|
|
[InlineData("01", "", true)]
|
|
[InlineData("", "01", true)]
|
|
[InlineData("01", "01", true)]
|
|
[InlineData("0102", "01", false)]
|
|
[InlineData("01", "0102", false)]
|
|
[InlineData("0102", "0201", false)]
|
|
public void ConditionalHashEquals_String(string? firstHash, string? secondHash, bool expected)
|
|
{
|
|
bool actual = MetadataExtensions.ConditionalHashEquals(firstHash, secondHash);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HashMatch
|
|
|
|
[Fact]
|
|
public void HashMatch_Disk_Mismatch_False()
|
|
{
|
|
Disk self = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = string.Empty,
|
|
};
|
|
Disk other = new Disk
|
|
{
|
|
[Disk.MD5Key] = string.Empty,
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Disk_PartialMD5_True()
|
|
{
|
|
Disk self = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = string.Empty,
|
|
};
|
|
Disk other = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Disk_PartialSHA1_True()
|
|
{
|
|
Disk self = new Disk
|
|
{
|
|
[Disk.MD5Key] = string.Empty,
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
Disk other = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Disk_FullMatch_True()
|
|
{
|
|
Disk self = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
Disk other = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_Mismatch_False()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_PartialMD5_True()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_PartialSHA1_True()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_PartialSHA256_True()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_PartialSpamSum_True()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Media_FullMatch_True()
|
|
{
|
|
Media self = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
Media other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_Mismatch_False()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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",
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialCRC16_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialCRC_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialCRC64_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialMD2_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialMD4_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialMD5_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialRIPEMD128_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialRIPEMD160_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialSHA1_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialSHA256_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialSHA384_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialSHA512_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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,
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_PartialSpamSum_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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",
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HashMatch_Rom_FullMatch_True()
|
|
{
|
|
Rom self = new Rom
|
|
{
|
|
[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",
|
|
};
|
|
Rom other = new Rom
|
|
{
|
|
[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.HashMatch(other);
|
|
Assert.True(actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HasZeroHash
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Disk_NoHash_True()
|
|
{
|
|
DictionaryBase self = new Disk();
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Disk_NonZeroHash_False()
|
|
{
|
|
DictionaryBase self = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Disk_ZeroMD5_True()
|
|
{
|
|
DictionaryBase self = new Disk
|
|
{
|
|
[Disk.MD5Key] = HashType.MD5.ZeroString,
|
|
[Disk.SHA1Key] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Disk_ZeroSHA1_True()
|
|
{
|
|
DictionaryBase self = new Disk
|
|
{
|
|
[Disk.MD5Key] = string.Empty,
|
|
[Disk.SHA1Key] = HashType.SHA1.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Disk_ZeroAll_True()
|
|
{
|
|
DictionaryBase self = new Disk
|
|
{
|
|
[Disk.MD5Key] = HashType.MD5.ZeroString,
|
|
[Disk.SHA1Key] = HashType.SHA1.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_NoHash_True()
|
|
{
|
|
DictionaryBase self = new Media();
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_NonZeroHash_False()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_ZeroMD5_True()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = HashType.MD5.ZeroString,
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_ZeroSHA1_True()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = HashType.SHA1.ZeroString,
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_ZeroSHA256_True()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = HashType.SHA256.ZeroString,
|
|
[Media.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_ZeroSpamSum_True()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = string.Empty,
|
|
[Media.SHA1Key] = string.Empty,
|
|
[Media.SHA256Key] = string.Empty,
|
|
[Media.SpamSumKey] = HashType.SpamSum.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Media_ZeroAll_True()
|
|
{
|
|
DictionaryBase self = new Media
|
|
{
|
|
[Media.MD5Key] = HashType.MD5.ZeroString,
|
|
[Media.SHA1Key] = HashType.SHA1.ZeroString,
|
|
[Media.SHA256Key] = HashType.SHA256.ZeroString,
|
|
[Media.SpamSumKey] = HashType.SpamSum.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_NoHash_True()
|
|
{
|
|
DictionaryBase self = new Rom();
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_NonZeroHash_False()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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.HasZeroHash();
|
|
Assert.False(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroCRC16_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = HashType.CRC16.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroCRC_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = string.Empty,
|
|
[Rom.CRCKey] = HashType.CRC32.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroCRC64_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = string.Empty,
|
|
[Rom.CRCKey] = string.Empty,
|
|
[Rom.CRC64Key] = HashType.CRC64.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroMD2_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = string.Empty,
|
|
[Rom.CRCKey] = string.Empty,
|
|
[Rom.CRC64Key] = string.Empty,
|
|
[Rom.MD2Key] = HashType.MD2.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroMD4_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = string.Empty,
|
|
[Rom.CRCKey] = string.Empty,
|
|
[Rom.CRC64Key] = string.Empty,
|
|
[Rom.MD2Key] = string.Empty,
|
|
[Rom.MD4Key] = HashType.MD4.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroMD5_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = string.Empty,
|
|
[Rom.CRCKey] = string.Empty,
|
|
[Rom.CRC64Key] = string.Empty,
|
|
[Rom.MD2Key] = string.Empty,
|
|
[Rom.MD4Key] = string.Empty,
|
|
[Rom.MD5Key] = HashType.MD5.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroRIPEMD128_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.RIPEMD128.ZeroString,
|
|
[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.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroRIPEMD160_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.RIPEMD160.ZeroString,
|
|
[Rom.SHA1Key] = string.Empty,
|
|
[Rom.SHA256Key] = string.Empty,
|
|
[Rom.SHA384Key] = string.Empty,
|
|
[Rom.SHA512Key] = string.Empty,
|
|
[Rom.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroSHA1_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.SHA1.ZeroString,
|
|
[Rom.SHA256Key] = string.Empty,
|
|
[Rom.SHA384Key] = string.Empty,
|
|
[Rom.SHA512Key] = string.Empty,
|
|
[Rom.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroSHA256_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.SHA256.ZeroString,
|
|
[Rom.SHA384Key] = string.Empty,
|
|
[Rom.SHA512Key] = string.Empty,
|
|
[Rom.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroSHA384_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.SHA384.ZeroString,
|
|
[Rom.SHA512Key] = string.Empty,
|
|
[Rom.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroSHA512_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.SHA512.ZeroString,
|
|
[Rom.SpamSumKey] = string.Empty,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroSpamSum_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[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] = HashType.SpamSum.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Rom_ZeroAll_True()
|
|
{
|
|
DictionaryBase self = new Rom
|
|
{
|
|
[Rom.CRC16Key] = HashType.CRC16.ZeroString,
|
|
[Rom.CRCKey] = HashType.CRC32.ZeroString,
|
|
[Rom.CRC64Key] = HashType.CRC64.ZeroString,
|
|
[Rom.MD2Key] = HashType.MD2.ZeroString,
|
|
[Rom.MD4Key] = HashType.MD4.ZeroString,
|
|
[Rom.MD5Key] = HashType.MD5.ZeroString,
|
|
[Rom.RIPEMD128Key] = HashType.RIPEMD128.ZeroString,
|
|
[Rom.RIPEMD160Key] = HashType.RIPEMD160.ZeroString,
|
|
[Rom.SHA1Key] = HashType.SHA1.ZeroString,
|
|
[Rom.SHA256Key] = HashType.SHA256.ZeroString,
|
|
[Rom.SHA384Key] = HashType.SHA384.ZeroString,
|
|
[Rom.SHA512Key] = HashType.SHA512.ZeroString,
|
|
[Rom.SpamSumKey] = HashType.SpamSum.ZeroString,
|
|
};
|
|
|
|
bool actual = self.HasZeroHash();
|
|
Assert.True(actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void HasZeroHash_Other_False()
|
|
{
|
|
DictionaryBase self = new Sample();
|
|
bool actual = self.HasZeroHash();
|
|
Assert.False(actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region FillMissingHashes
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Disk_BothEmpty()
|
|
{
|
|
DictionaryBase self = new Disk();
|
|
DictionaryBase other = new Disk();
|
|
|
|
self.FillMissingHashes(other);
|
|
Assert.Single(self);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Disk_AllMissing()
|
|
{
|
|
DictionaryBase self = new Disk();
|
|
DictionaryBase other = new Disk
|
|
{
|
|
[Disk.MD5Key] = "XXXXXX",
|
|
[Disk.SHA1Key] = "XXXXXX",
|
|
};
|
|
|
|
self.FillMissingHashes(other);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Media_BothEmpty()
|
|
{
|
|
DictionaryBase self = new Media();
|
|
DictionaryBase other = new Media();
|
|
self.FillMissingHashes(other);
|
|
Assert.Single(self);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Media_AllMissing()
|
|
{
|
|
DictionaryBase self = new Media();
|
|
DictionaryBase other = new Media
|
|
{
|
|
[Media.MD5Key] = "XXXXXX",
|
|
[Media.SHA1Key] = "XXXXXX",
|
|
[Media.SHA256Key] = "XXXXXX",
|
|
[Media.SpamSumKey] = "XXXXXX",
|
|
};
|
|
|
|
self.FillMissingHashes(other);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Rom_BothEmpty()
|
|
{
|
|
DictionaryBase self = new Rom();
|
|
DictionaryBase other = new Rom();
|
|
self.FillMissingHashes(other);
|
|
Assert.Single(self);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillMissingHashes_Rom_AllMissing()
|
|
{
|
|
DictionaryBase self = new Rom();
|
|
DictionaryBase other = new Rom
|
|
{
|
|
[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",
|
|
};
|
|
|
|
self.FillMissingHashes(other);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region String to Enum
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("cpu", ChipType.CPU)]
|
|
[InlineData("audio", ChipType.Audio)]
|
|
public void AsChipTypeTest(string? field, ChipType? expected)
|
|
{
|
|
ChipType? actual = field.AsChipType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("joy", ControlType.Joy)]
|
|
[InlineData("stick", ControlType.Stick)]
|
|
[InlineData("paddle", ControlType.Paddle)]
|
|
[InlineData("pedal", ControlType.Pedal)]
|
|
[InlineData("lightgun", ControlType.Lightgun)]
|
|
[InlineData("positional", ControlType.Positional)]
|
|
[InlineData("dial", ControlType.Dial)]
|
|
[InlineData("trackball", ControlType.Trackball)]
|
|
[InlineData("mouse", ControlType.Mouse)]
|
|
[InlineData("only_buttons", ControlType.OnlyButtons)]
|
|
[InlineData("keypad", ControlType.Keypad)]
|
|
[InlineData("keyboard", ControlType.Keyboard)]
|
|
[InlineData("mahjong", ControlType.Mahjong)]
|
|
[InlineData("hanafuda", ControlType.Hanafuda)]
|
|
[InlineData("gambling", ControlType.Gambling)]
|
|
public void AsControlTypeTest(string? field, ControlType? expected)
|
|
{
|
|
ControlType? actual = field.AsControlType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("unknown", DeviceType.Unknown)]
|
|
[InlineData("cartridge", DeviceType.Cartridge)]
|
|
[InlineData("floppydisk", DeviceType.FloppyDisk)]
|
|
[InlineData("harddisk", DeviceType.HardDisk)]
|
|
[InlineData("cylinder", DeviceType.Cylinder)]
|
|
[InlineData("cassette", DeviceType.Cassette)]
|
|
[InlineData("punchcard", DeviceType.PunchCard)]
|
|
[InlineData("punchtape", DeviceType.PunchTape)]
|
|
[InlineData("printout", DeviceType.Printout)]
|
|
[InlineData("serial", DeviceType.Serial)]
|
|
[InlineData("parallel", DeviceType.Parallel)]
|
|
[InlineData("snapshot", DeviceType.Snapshot)]
|
|
[InlineData("quickload", DeviceType.QuickLoad)]
|
|
[InlineData("memcard", DeviceType.MemCard)]
|
|
[InlineData("cdrom", DeviceType.CDROM)]
|
|
[InlineData("magtape", DeviceType.MagTape)]
|
|
[InlineData("romimage", DeviceType.ROMImage)]
|
|
[InlineData("midiin", DeviceType.MIDIIn)]
|
|
[InlineData("midiout", DeviceType.MIDIOut)]
|
|
[InlineData("picture", DeviceType.Picture)]
|
|
[InlineData("vidfile", DeviceType.VidFile)]
|
|
public void AsDeviceTypeTest(string? field, DeviceType? expected)
|
|
{
|
|
DeviceType? actual = field.AsDeviceType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("raster", DisplayType.Raster)]
|
|
[InlineData("vector", DisplayType.Vector)]
|
|
[InlineData("lcd", DisplayType.LCD)]
|
|
[InlineData("svg", DisplayType.SVG)]
|
|
[InlineData("unknown", DisplayType.Unknown)]
|
|
public void AsDisplayTypeTest(string? field, DisplayType? expected)
|
|
{
|
|
DisplayType? actual = field.AsDisplayType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("big", Endianness.Big)]
|
|
[InlineData("little", Endianness.Little)]
|
|
public void AsEndiannessTest(string? field, Endianness? expected)
|
|
{
|
|
Endianness? actual = field.AsEndianness();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("unemulated", FeatureStatus.Unemulated)]
|
|
[InlineData("imperfect", FeatureStatus.Imperfect)]
|
|
public void AsFeatureStatusTest(string? field, FeatureStatus? expected)
|
|
{
|
|
FeatureStatus? actual = field.AsFeatureStatus();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("protection", FeatureType.Protection)]
|
|
[InlineData("palette", FeatureType.Palette)]
|
|
[InlineData("graphics", FeatureType.Graphics)]
|
|
[InlineData("sound", FeatureType.Sound)]
|
|
[InlineData("controls", FeatureType.Controls)]
|
|
[InlineData("keyboard", FeatureType.Keyboard)]
|
|
[InlineData("mouse", FeatureType.Mouse)]
|
|
[InlineData("microphone", FeatureType.Microphone)]
|
|
[InlineData("camera", FeatureType.Camera)]
|
|
[InlineData("disk", FeatureType.Disk)]
|
|
[InlineData("printer", FeatureType.Printer)]
|
|
[InlineData("lan", FeatureType.Lan)]
|
|
[InlineData("wan", FeatureType.Wan)]
|
|
[InlineData("timing", FeatureType.Timing)]
|
|
public void AsFeatureTypeTest(string? field, FeatureType? expected)
|
|
{
|
|
FeatureType? actual = field.AsFeatureType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("none", ItemStatus.None)]
|
|
[InlineData("no", ItemStatus.None)]
|
|
[InlineData("good", ItemStatus.Good)]
|
|
[InlineData("baddump", ItemStatus.BadDump)]
|
|
[InlineData("nodump", ItemStatus.Nodump)]
|
|
[InlineData("yes", ItemStatus.Nodump)]
|
|
[InlineData("verified", ItemStatus.Verified)]
|
|
public void AsItemStatusTest(string? field, ItemStatus? expected)
|
|
{
|
|
ItemStatus? actual = field.AsItemStatus();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("load16_byte", LoadFlag.Load16Byte)]
|
|
[InlineData("load16_word", LoadFlag.Load16Word)]
|
|
[InlineData("load16_word_swap", LoadFlag.Load16WordSwap)]
|
|
[InlineData("load32_byte", LoadFlag.Load32Byte)]
|
|
[InlineData("load32_word", LoadFlag.Load32Word)]
|
|
[InlineData("load32_word_swap", LoadFlag.Load32WordSwap)]
|
|
[InlineData("load32_dword", LoadFlag.Load32DWord)]
|
|
[InlineData("load64_word", LoadFlag.Load64Word)]
|
|
[InlineData("load64_word_swap", LoadFlag.Load64WordSwap)]
|
|
[InlineData("reload", LoadFlag.Reload)]
|
|
[InlineData("fill", LoadFlag.Fill)]
|
|
[InlineData("continue", LoadFlag.Continue)]
|
|
[InlineData("reload_plain", LoadFlag.ReloadPlain)]
|
|
[InlineData("ignore", LoadFlag.Ignore)]
|
|
public void AsLoadFlagTest(string? field, LoadFlag? expected)
|
|
{
|
|
LoadFlag? actual = field.AsLoadFlag();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, MergingFlag.None)]
|
|
[InlineData("none", MergingFlag.None)]
|
|
[InlineData("split", MergingFlag.Split)]
|
|
[InlineData("merged", MergingFlag.Merged)]
|
|
[InlineData("nonmerged", MergingFlag.NonMerged)]
|
|
[InlineData("unmerged", MergingFlag.NonMerged)]
|
|
[InlineData("fullmerged", MergingFlag.FullMerged)]
|
|
[InlineData("device", MergingFlag.DeviceNonMerged)]
|
|
[InlineData("devicenonmerged", MergingFlag.DeviceNonMerged)]
|
|
[InlineData("deviceunmerged", MergingFlag.DeviceNonMerged)]
|
|
[InlineData("full", MergingFlag.FullNonMerged)]
|
|
[InlineData("fullnonmerged", MergingFlag.FullNonMerged)]
|
|
[InlineData("fullunmerged", MergingFlag.FullNonMerged)]
|
|
public void AsMergingFlagTest(string? field, MergingFlag expected)
|
|
{
|
|
MergingFlag actual = field.AsMergingFlag();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, NodumpFlag.None)]
|
|
[InlineData("none", NodumpFlag.None)]
|
|
[InlineData("obsolete", NodumpFlag.Obsolete)]
|
|
[InlineData("required", NodumpFlag.Required)]
|
|
[InlineData("ignore", NodumpFlag.Ignore)]
|
|
public void AsNodumpFlagTest(string? field, NodumpFlag expected)
|
|
{
|
|
NodumpFlag actual = field.AsNodumpFlag();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("rom", OpenMSXSubType.Rom)]
|
|
[InlineData("megarom", OpenMSXSubType.MegaRom)]
|
|
[InlineData("sccpluscart", OpenMSXSubType.SCCPlusCart)]
|
|
public void AsOpenMSXSubTypeTest(string? field, OpenMSXSubType? expected)
|
|
{
|
|
OpenMSXSubType? actual = field.AsOpenMSXSubType();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, PackingFlag.None)]
|
|
[InlineData("none", PackingFlag.None)]
|
|
[InlineData("yes", PackingFlag.Zip)]
|
|
[InlineData("zip", PackingFlag.Zip)]
|
|
[InlineData("no", PackingFlag.Unzip)]
|
|
[InlineData("unzip", PackingFlag.Unzip)]
|
|
[InlineData("partial", PackingFlag.Partial)]
|
|
[InlineData("flat", PackingFlag.Flat)]
|
|
[InlineData("fileonly", PackingFlag.FileOnly)]
|
|
public void AsPackingFlagTest(string? field, PackingFlag expected)
|
|
{
|
|
PackingFlag actual = field.AsPackingFlag();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("eq", Relation.Equal)]
|
|
[InlineData("ne", Relation.NotEqual)]
|
|
[InlineData("gt", Relation.GreaterThan)]
|
|
[InlineData("le", Relation.LessThanOrEqual)]
|
|
[InlineData("lt", Relation.LessThan)]
|
|
[InlineData("ge", Relation.GreaterThanOrEqual)]
|
|
public void AsRelationTest(string? field, Relation? expected)
|
|
{
|
|
Relation? actual = field.AsRelation();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("no", Runnable.No)]
|
|
[InlineData("partial", Runnable.Partial)]
|
|
[InlineData("yes", Runnable.Yes)]
|
|
public void AsRunnableTest(string? field, Runnable? expected)
|
|
{
|
|
Runnable? actual = field.AsRunnable();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("none", SoftwareListStatus.None)]
|
|
[InlineData("original", SoftwareListStatus.Original)]
|
|
[InlineData("compatible", SoftwareListStatus.Compatible)]
|
|
public void AsSoftwareListStatusTest(string? field, SoftwareListStatus? expected)
|
|
{
|
|
SoftwareListStatus? actual = field.AsSoftwareListStatus();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("no", Supported.No)]
|
|
[InlineData("unsupported", Supported.No)]
|
|
[InlineData("partial", Supported.Partial)]
|
|
[InlineData("yes", Supported.Yes)]
|
|
[InlineData("supported", Supported.Yes)]
|
|
public void AsSupportedTest(string? field, Supported? expected)
|
|
{
|
|
Supported? actual = field.AsSupported();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("good", SupportStatus.Good)]
|
|
[InlineData("imperfect", SupportStatus.Imperfect)]
|
|
[InlineData("preliminary", SupportStatus.Preliminary)]
|
|
public void AsSupportStatusTest(string? field, SupportStatus? expected)
|
|
{
|
|
SupportStatus? actual = field.AsSupportStatus();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData("INVALID", null)]
|
|
[InlineData("yes", true)]
|
|
[InlineData("True", true)]
|
|
[InlineData("no", false)]
|
|
[InlineData("False", false)]
|
|
public void AsYesNoTest(string? field, bool? expected)
|
|
{
|
|
bool? actual = field.AsYesNo();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Enum to String
|
|
|
|
[Theory]
|
|
[InlineData((ChipType)int.MaxValue, null)]
|
|
[InlineData(ChipType.CPU, "cpu")]
|
|
[InlineData(ChipType.Audio, "audio")]
|
|
public void FromChipTypeTest(ChipType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((ControlType)int.MaxValue, null)]
|
|
[InlineData(ControlType.Joy, "joy")]
|
|
[InlineData(ControlType.Stick, "stick")]
|
|
[InlineData(ControlType.Paddle, "paddle")]
|
|
[InlineData(ControlType.Pedal, "pedal")]
|
|
[InlineData(ControlType.Lightgun, "lightgun")]
|
|
[InlineData(ControlType.Positional, "positional")]
|
|
[InlineData(ControlType.Dial, "dial")]
|
|
[InlineData(ControlType.Trackball, "trackball")]
|
|
[InlineData(ControlType.Mouse, "mouse")]
|
|
[InlineData(ControlType.OnlyButtons, "only_buttons")]
|
|
[InlineData(ControlType.Keypad, "keypad")]
|
|
[InlineData(ControlType.Keyboard, "keyboard")]
|
|
[InlineData(ControlType.Mahjong, "mahjong")]
|
|
[InlineData(ControlType.Hanafuda, "hanafuda")]
|
|
[InlineData(ControlType.Gambling, "gambling")]
|
|
public void FromControlTypeTest(ControlType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((DeviceType)int.MaxValue, null)]
|
|
[InlineData(DeviceType.Unknown, "unknown")]
|
|
[InlineData(DeviceType.Cartridge, "cartridge")]
|
|
[InlineData(DeviceType.FloppyDisk, "floppydisk")]
|
|
[InlineData(DeviceType.HardDisk, "harddisk")]
|
|
[InlineData(DeviceType.Cylinder, "cylinder")]
|
|
[InlineData(DeviceType.Cassette, "cassette")]
|
|
[InlineData(DeviceType.PunchCard, "punchcard")]
|
|
[InlineData(DeviceType.PunchTape, "punchtape")]
|
|
[InlineData(DeviceType.Printout, "printout")]
|
|
[InlineData(DeviceType.Serial, "serial")]
|
|
[InlineData(DeviceType.Parallel, "parallel")]
|
|
[InlineData(DeviceType.Snapshot, "snapshot")]
|
|
[InlineData(DeviceType.QuickLoad, "quickload")]
|
|
[InlineData(DeviceType.MemCard, "memcard")]
|
|
[InlineData(DeviceType.CDROM, "cdrom")]
|
|
[InlineData(DeviceType.MagTape, "magtape")]
|
|
[InlineData(DeviceType.ROMImage, "romimage")]
|
|
[InlineData(DeviceType.MIDIIn, "midiin")]
|
|
[InlineData(DeviceType.MIDIOut, "midiout")]
|
|
[InlineData(DeviceType.Picture, "picture")]
|
|
[InlineData(DeviceType.VidFile, "vidfile")]
|
|
public void FromDeviceTypeTest(DeviceType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((DisplayType)int.MaxValue, null)]
|
|
[InlineData(DisplayType.Raster, "raster")]
|
|
[InlineData(DisplayType.Vector, "vector")]
|
|
[InlineData(DisplayType.LCD, "lcd")]
|
|
[InlineData(DisplayType.SVG, "svg")]
|
|
[InlineData(DisplayType.Unknown, "unknown")]
|
|
public void FromDisplayTypeTest(DisplayType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((Endianness)int.MaxValue, null)]
|
|
[InlineData(Endianness.Big, "big")]
|
|
[InlineData(Endianness.Little, "little")]
|
|
public void FromEndiannessTest(Endianness field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((FeatureStatus)int.MaxValue, null)]
|
|
[InlineData(FeatureStatus.Unemulated, "unemulated")]
|
|
[InlineData(FeatureStatus.Imperfect, "imperfect")]
|
|
public void FromFeatureStatusTest(FeatureStatus field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((FeatureType)int.MaxValue, null)]
|
|
[InlineData(FeatureType.Protection, "protection")]
|
|
[InlineData(FeatureType.Palette, "palette")]
|
|
[InlineData(FeatureType.Graphics, "graphics")]
|
|
[InlineData(FeatureType.Sound, "sound")]
|
|
[InlineData(FeatureType.Controls, "controls")]
|
|
[InlineData(FeatureType.Keyboard, "keyboard")]
|
|
[InlineData(FeatureType.Mouse, "mouse")]
|
|
[InlineData(FeatureType.Microphone, "microphone")]
|
|
[InlineData(FeatureType.Camera, "camera")]
|
|
[InlineData(FeatureType.Disk, "disk")]
|
|
[InlineData(FeatureType.Printer, "printer")]
|
|
[InlineData(FeatureType.Lan, "lan")]
|
|
[InlineData(FeatureType.Wan, "wan")]
|
|
[InlineData(FeatureType.Timing, "timing")]
|
|
public void FromFeatureTypeTest(FeatureType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((ItemStatus)int.MaxValue, true, null)]
|
|
[InlineData((ItemStatus)int.MaxValue, false, null)]
|
|
[InlineData(ItemStatus.None, true, "no")]
|
|
[InlineData(ItemStatus.None, false, "none")]
|
|
[InlineData(ItemStatus.Good, true, "good")]
|
|
[InlineData(ItemStatus.Good, false, "good")]
|
|
[InlineData(ItemStatus.BadDump, true, "baddump")]
|
|
[InlineData(ItemStatus.BadDump, false, "baddump")]
|
|
[InlineData(ItemStatus.Nodump, true, "yes")]
|
|
[InlineData(ItemStatus.Nodump, false, "nodump")]
|
|
[InlineData(ItemStatus.Verified, true, "verified")]
|
|
[InlineData(ItemStatus.Verified, false, "verified")]
|
|
public void FromItemStatusTest(ItemStatus field, bool useSecond, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue(useSecond);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((LoadFlag)int.MaxValue, null)]
|
|
[InlineData(LoadFlag.Load16Byte, "load16_byte")]
|
|
[InlineData(LoadFlag.Load16Word, "load16_word")]
|
|
[InlineData(LoadFlag.Load16WordSwap, "load16_word_swap")]
|
|
[InlineData(LoadFlag.Load32Byte, "load32_byte")]
|
|
[InlineData(LoadFlag.Load32Word, "load32_word")]
|
|
[InlineData(LoadFlag.Load32WordSwap, "load32_word_swap")]
|
|
[InlineData(LoadFlag.Load32DWord, "load32_dword")]
|
|
[InlineData(LoadFlag.Load64Word, "load64_word")]
|
|
[InlineData(LoadFlag.Load64WordSwap, "load64_word_swap")]
|
|
[InlineData(LoadFlag.Reload, "reload")]
|
|
[InlineData(LoadFlag.Fill, "fill")]
|
|
[InlineData(LoadFlag.Continue, "continue")]
|
|
[InlineData(LoadFlag.ReloadPlain, "reload_plain")]
|
|
[InlineData(LoadFlag.Ignore, "ignore")]
|
|
public void FromLoadFlagTest(LoadFlag field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(MergingFlag.None, true, "none")]
|
|
[InlineData(MergingFlag.None, false, "none")]
|
|
[InlineData(MergingFlag.Split, true, "split")]
|
|
[InlineData(MergingFlag.Split, false, "split")]
|
|
[InlineData(MergingFlag.Merged, true, "merged")]
|
|
[InlineData(MergingFlag.Merged, false, "merged")]
|
|
[InlineData(MergingFlag.NonMerged, true, "unmerged")]
|
|
[InlineData(MergingFlag.NonMerged, false, "nonmerged")]
|
|
[InlineData(MergingFlag.FullMerged, true, "fullmerged")]
|
|
[InlineData(MergingFlag.FullMerged, false, "fullmerged")]
|
|
[InlineData(MergingFlag.DeviceNonMerged, true, "devicenonmerged")]
|
|
[InlineData(MergingFlag.DeviceNonMerged, false, "device")]
|
|
[InlineData(MergingFlag.FullNonMerged, true, "fullnonmerged")]
|
|
[InlineData(MergingFlag.FullNonMerged, false, "full")]
|
|
public void FromMergingFlagTest(MergingFlag field, bool useSecond, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue(useSecond);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(NodumpFlag.None, "none")]
|
|
[InlineData(NodumpFlag.Obsolete, "obsolete")]
|
|
[InlineData(NodumpFlag.Required, "required")]
|
|
[InlineData(NodumpFlag.Ignore, "ignore")]
|
|
public void FromNodumpFlagTest(NodumpFlag field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((OpenMSXSubType)int.MaxValue, null)]
|
|
[InlineData(OpenMSXSubType.Rom, "rom")]
|
|
[InlineData(OpenMSXSubType.MegaRom, "megarom")]
|
|
[InlineData(OpenMSXSubType.SCCPlusCart, "sccpluscart")]
|
|
public void FromOpenMSXSubTypeTest(OpenMSXSubType field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(PackingFlag.None, true, "none")]
|
|
[InlineData(PackingFlag.None, false, "none")]
|
|
[InlineData(PackingFlag.Zip, true, "yes")]
|
|
[InlineData(PackingFlag.Zip, false, "zip")]
|
|
[InlineData(PackingFlag.Unzip, true, "no")]
|
|
[InlineData(PackingFlag.Unzip, false, "unzip")]
|
|
[InlineData(PackingFlag.Partial, true, "partial")]
|
|
[InlineData(PackingFlag.Partial, false, "partial")]
|
|
[InlineData(PackingFlag.Flat, true, "flat")]
|
|
[InlineData(PackingFlag.Flat, false, "flat")]
|
|
[InlineData(PackingFlag.FileOnly, true, "fileonly")]
|
|
[InlineData(PackingFlag.FileOnly, false, "fileonly")]
|
|
public void FromPackingFlagTest(PackingFlag field, bool useSecond, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue(useSecond);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((Relation)int.MaxValue, null)]
|
|
[InlineData(Relation.Equal, "eq")]
|
|
[InlineData(Relation.NotEqual, "ne")]
|
|
[InlineData(Relation.GreaterThan, "gt")]
|
|
[InlineData(Relation.LessThanOrEqual, "le")]
|
|
[InlineData(Relation.LessThan, "lt")]
|
|
[InlineData(Relation.GreaterThanOrEqual, "ge")]
|
|
public void FromRelationTest(Relation field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((Runnable)int.MaxValue, null)]
|
|
[InlineData(Runnable.No, "no")]
|
|
[InlineData(Runnable.Partial, "partial")]
|
|
[InlineData(Runnable.Yes, "yes")]
|
|
public void FromRunnableTest(Runnable field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((SoftwareListStatus)int.MaxValue, null)]
|
|
[InlineData(SoftwareListStatus.None, "none")]
|
|
[InlineData(SoftwareListStatus.Original, "original")]
|
|
[InlineData(SoftwareListStatus.Compatible, "compatible")]
|
|
public void FromSoftwareListStatusTest(SoftwareListStatus field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((Supported)int.MaxValue, true, null)]
|
|
[InlineData((Supported)int.MaxValue, false, null)]
|
|
[InlineData(Supported.No, true, "unsupported")]
|
|
[InlineData(Supported.No, false, "no")]
|
|
[InlineData(Supported.Partial, true, "partial")]
|
|
[InlineData(Supported.Partial, false, "partial")]
|
|
[InlineData(Supported.Yes, true, "supported")]
|
|
[InlineData(Supported.Yes, false, "yes")]
|
|
public void FromSupportedTest(Supported field, bool useSecond, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue(useSecond);
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData((SupportStatus)int.MaxValue, null)]
|
|
[InlineData(SupportStatus.Good, "good")]
|
|
[InlineData(SupportStatus.Imperfect, "imperfect")]
|
|
[InlineData(SupportStatus.Preliminary, "preliminary")]
|
|
public void FromSupportStatusTest(SupportStatus field, string? expected)
|
|
{
|
|
string? actual = field.AsStringValue();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null, null)]
|
|
[InlineData(true, "yes")]
|
|
[InlineData(false, "no")]
|
|
public void FromYesNo(bool? field, string? expected)
|
|
{
|
|
string? actual = field.FromYesNo();
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|