Files
SabreTools/SabreTools.Test/DatFiles/SetterTests.cs
Matt Nadareski 728b5d6b27 Perform mass cleanup
This is cleanup based on both new .NET functionality (in 6 and 7) as well as a ton of simplifications and things that were missed that were caught due to the cleanup.
2023-04-19 16:39:58 -04:00

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()
{
DatItemMappings = 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()
{
MachineMappings = 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",
}
};
}
}
}