44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using TuneBoss.Core.Models;
|
|
using Xunit;
|
|
|
|
namespace TuneBoss.Core.Tests;
|
|
|
|
public class MiscFieldRegistryTests
|
|
{
|
|
private static int BlockSize(MiscBlock b) => b switch
|
|
{
|
|
MiscBlock.Core => 136,
|
|
MiscBlock.LaunchFuel => 12,
|
|
MiscBlock.LaunchFuel2 => 12,
|
|
MiscBlock.AuxOut => 12,
|
|
MiscBlock.Extended => 152,
|
|
_ => 0,
|
|
};
|
|
|
|
[Fact]
|
|
public void All_field_indices_are_within_their_block()
|
|
{
|
|
foreach (var f in MiscFieldRegistry.All)
|
|
Assert.InRange(f.Index, 0, BlockSize(f.Block) - 1);
|
|
}
|
|
|
|
[Fact]
|
|
public void No_two_fields_share_a_block_and_index()
|
|
{
|
|
var dupes = MiscFieldRegistry.All
|
|
.GroupBy(f => (f.Block, f.Index))
|
|
.Where(g => g.Count() > 1)
|
|
.Select(g => $"{g.Key.Block}[{g.Key.Index}]: {string.Join(", ", g.Select(x => x.Label))}")
|
|
.ToList();
|
|
|
|
Assert.True(dupes.Count == 0, "Duplicate (block,index) mappings:\n" + string.Join("\n", dupes));
|
|
}
|
|
|
|
[Fact]
|
|
public void All_labels_are_nonblank()
|
|
{
|
|
foreach (var f in MiscFieldRegistry.All)
|
|
Assert.False(string.IsNullOrWhiteSpace(f.Label));
|
|
}
|
|
}
|