2020-12-19 16:12:04 -08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using SabreTools.Core;
|
2021-02-01 14:07:50 -08:00
|
|
|
using SabreTools.DatFiles;
|
2020-12-19 16:12:04 -08:00
|
|
|
using SabreTools.DatItems;
|
2021-02-02 10:23:43 -08:00
|
|
|
using SabreTools.DatItems.Formats;
|
2020-12-19 16:12:04 -08:00
|
|
|
using Xunit;
|
|
|
|
|
|
2021-02-01 14:07:50 -08:00
|
|
|
namespace SabreTools.Test.DatFiles
|
2020-12-19 16:12:04 -08:00
|
|
|
{
|
2021-02-01 13:11:12 -08:00
|
|
|
public class SetterTests
|
2020-12-19 16:12:04 -08:00
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SetFieldsDatItemTest()
|
|
|
|
|
{
|
|
|
|
|
var datItem = CreateDatItem();
|
2023-04-19 16:39:58 -04:00
|
|
|
Setter setter = new()
|
2021-02-01 14:07:50 -08:00
|
|
|
{
|
2024-03-05 17:17:40 -05:00
|
|
|
ItemFieldMappings = new Dictionary<DatItemField, string> { [DatItemField.Name] = "bar" }
|
2021-02-01 14:07:50 -08:00
|
|
|
};
|
|
|
|
|
setter.SetFields(datItem);
|
2020-12-19 16:12:04 -08:00
|
|
|
Assert.Equal("bar", datItem.GetName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SetFieldsMachineTest()
|
|
|
|
|
{
|
|
|
|
|
var datItem = CreateDatItem();
|
2023-04-19 16:39:58 -04:00
|
|
|
Setter setter = new()
|
2021-02-01 14:07:50 -08:00
|
|
|
{
|
2024-03-05 17:17:40 -05:00
|
|
|
MachineFieldMappings = new Dictionary<MachineField, string> { [MachineField.Name] = "foo" }
|
2021-02-01 14:07:50 -08:00
|
|
|
};
|
|
|
|
|
setter.SetFields(datItem.Machine);
|
2020-12-19 16:12:04 -08:00
|
|
|
Assert.Equal("foo", datItem.Machine.Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generate a consistent DatItem for testing
|
|
|
|
|
/// </summary>
|
2023-04-19 16:39:58 -04:00
|
|
|
private static DatItem CreateDatItem()
|
2020-12-19 16:12:04 -08:00
|
|
|
{
|
|
|
|
|
return new Rom
|
|
|
|
|
{
|
|
|
|
|
Name = "foo",
|
|
|
|
|
Machine = new Machine
|
|
|
|
|
{
|
|
|
|
|
Name = "bar",
|
|
|
|
|
Description = "bar",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|