mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
|
|
using SabreTools.Core;
|
|
using SabreTools.DatFiles;
|
|
using SabreTools.DatItems;
|
|
using SabreTools.DatItems.Formats;
|
|
using Xunit;
|
|
|
|
namespace SabreTools.Test.DatFiles
|
|
{
|
|
public class SetterTests
|
|
{
|
|
[Fact]
|
|
public void SetFieldsDatItemTest()
|
|
{
|
|
var datItem = CreateDatItem();
|
|
Setter setter = new()
|
|
{
|
|
ItemFieldMappings = new Dictionary<DatItemField, string> { [DatItemField.Name] = "bar" }
|
|
};
|
|
setter.SetFields(datItem);
|
|
Assert.Equal("bar", datItem.GetName());
|
|
}
|
|
|
|
[Fact]
|
|
public void SetFieldsMachineTest()
|
|
{
|
|
var datItem = CreateDatItem();
|
|
Setter setter = new()
|
|
{
|
|
MachineFieldMappings = new Dictionary<MachineField, string> { [MachineField.Name] = "foo" }
|
|
};
|
|
setter.SetFields(datItem.Machine);
|
|
Assert.Equal("foo", datItem.Machine.Name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generate a consistent DatItem for testing
|
|
/// </summary>
|
|
private static DatItem CreateDatItem()
|
|
{
|
|
return new Rom
|
|
{
|
|
Name = "foo",
|
|
Machine = new Machine
|
|
{
|
|
Name = "bar",
|
|
Description = "bar",
|
|
}
|
|
};
|
|
}
|
|
}
|
|
} |