mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
190 lines
5.8 KiB
C#
190 lines
5.8 KiB
C#
using SabreTools.DatItems.Formats;
|
|
using Xunit;
|
|
|
|
namespace SabreTools.DatItems.Test
|
|
{
|
|
public class DatItemTests
|
|
{
|
|
#region CopyMachineInformation
|
|
|
|
// TODO: Implement CopyMachineInformation tests
|
|
|
|
#endregion
|
|
|
|
#region CompareTo
|
|
|
|
// TODO: Implement CompareTo tests
|
|
|
|
#endregion
|
|
|
|
#region Equals
|
|
|
|
// TODO: Implement Equals tests
|
|
|
|
#endregion
|
|
|
|
#region GetDuplicateStatus
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_NullOther_NoDupe()
|
|
{
|
|
DatItem item = new Rom();
|
|
DatItem? lastItem = null;
|
|
var actual = item.GetDuplicateStatus(lastItem);
|
|
Assert.Equal((DupeType)0x00, actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_DifferentTypes_NoDupe()
|
|
{
|
|
var rom = new Rom();
|
|
DatItem? lastItem = new Disk();
|
|
var actual = rom.GetDuplicateStatus(lastItem);
|
|
Assert.Equal((DupeType)0x00, actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_DifferentSource_NameMatch_ExternalAll()
|
|
{
|
|
var machineA = new Machine();
|
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var machineB = new Machine();
|
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var romA = new Rom();
|
|
romA.SetName("same-name");
|
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romA.CopyMachineInformation(machineA);
|
|
|
|
var romB = new Rom();
|
|
romB.SetName("same-name");
|
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(1));
|
|
romB.CopyMachineInformation(machineB);
|
|
|
|
var actual = romA.GetDuplicateStatus(romB);
|
|
Assert.Equal(DupeType.External | DupeType.All, actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_DifferentSource_NoNameMatch_ExternalHash()
|
|
{
|
|
var machineA = new Machine();
|
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var machineB = new Machine();
|
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "not-name-same");
|
|
|
|
var romA = new Rom();
|
|
romA.SetName("same-name");
|
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romA.CopyMachineInformation(machineA);
|
|
|
|
var romB = new Rom();
|
|
romB.SetName("same-name");
|
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(1));
|
|
romB.CopyMachineInformation(machineB);
|
|
|
|
var actual = romA.GetDuplicateStatus(romB);
|
|
Assert.Equal(DupeType.External | DupeType.Hash, actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_SameSource_NameMatch_InternalAll()
|
|
{
|
|
var machineA = new Machine();
|
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var machineB = new Machine();
|
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var romA = new Rom();
|
|
romA.SetName("same-name");
|
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romA.CopyMachineInformation(machineA);
|
|
|
|
var romB = new Rom();
|
|
romB.SetName("same-name");
|
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romB.CopyMachineInformation(machineB);
|
|
|
|
var actual = romA.GetDuplicateStatus(romB);
|
|
Assert.Equal(DupeType.Internal | DupeType.All, actual);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDuplicateStatus_SameSource_NoNameMatch_InternalHash()
|
|
{
|
|
var machineA = new Machine();
|
|
machineA.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "name-same");
|
|
|
|
var machineB = new Machine();
|
|
machineB.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, "not-name-same");
|
|
|
|
var romA = new Rom();
|
|
romA.SetName("same-name");
|
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romA.CopyMachineInformation(machineA);
|
|
|
|
var romB = new Rom();
|
|
romB.SetName("same-name");
|
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
|
romB.CopyMachineInformation(machineB);
|
|
|
|
var actual = romA.GetDuplicateStatus(romB);
|
|
Assert.Equal(DupeType.Internal | DupeType.Hash, actual);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetDuplicateStatusDB
|
|
|
|
// TODO: Implement GetDuplicateStatusDB tests
|
|
|
|
#endregion
|
|
|
|
#region PassesFilter
|
|
|
|
// TODO: Implement PassesFilter tests
|
|
|
|
#endregion
|
|
|
|
#region GetKey
|
|
|
|
// TODO: Implement GetKey tests
|
|
|
|
#endregion
|
|
|
|
#region GetName
|
|
|
|
// TODO: Implement GetName tests
|
|
|
|
#endregion
|
|
|
|
#region SetName
|
|
|
|
// TODO: Implement SetName tests
|
|
|
|
#endregion
|
|
|
|
#region Clone
|
|
|
|
// TODO: Implement Clone tests
|
|
|
|
#endregion
|
|
|
|
#region GetInternalClone
|
|
|
|
// TODO: Implement GetInternalClone tests
|
|
|
|
#endregion
|
|
}
|
|
} |