Initial Commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using TuneBoss.Core.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace TuneBoss.Core.Tests;
|
||||
|
||||
public class MiscValuesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Core_is_sliced_from_offset_4()
|
||||
{
|
||||
var data = new byte[136];
|
||||
for (int i = 0; i < data.Length; i++) data[i] = (byte)i;
|
||||
|
||||
var mv = MiscValues.FromPayloads(TestData.WithHeader(data, 0x46));
|
||||
|
||||
Assert.Equal(136, mv.Core.Length);
|
||||
Assert.Equal(0, mv.Core[0]); // header skipped
|
||||
Assert.Equal(135, mv.Core[135]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Short_core_payload_yields_empty()
|
||||
{
|
||||
// 4 header + 100 data = 104 < 4 + 136, so Slice returns empty.
|
||||
var mv = MiscValues.FromPayloads(TestData.WithHeader(new byte[100]));
|
||||
Assert.Empty(mv.Core);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Optional_blocks_default_to_empty()
|
||||
{
|
||||
var mv = MiscValues.FromPayloads(TestData.WithHeader(new byte[136]));
|
||||
Assert.Empty(mv.LaunchFuel);
|
||||
Assert.Empty(mv.LaunchFuel2);
|
||||
Assert.Empty(mv.AuxOut);
|
||||
Assert.Empty(mv.Extended);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(EcuVariant.SingleCylinder, 0x29)]
|
||||
[InlineData(EcuVariant.TwoCylinder, 0x73)]
|
||||
[InlineData(EcuVariant.TwoCylinderR15, 0x97)]
|
||||
public void ExtendedLengthFor_matches_variant(EcuVariant v, int expected)
|
||||
{
|
||||
Assert.Equal(expected, MiscValues.ExtendedLengthFor(v));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Extended_slice_size_follows_payload_length()
|
||||
{
|
||||
int n = MiscValues.ExtendedLengthFor(EcuVariant.TwoCylinderR15); // 0x97
|
||||
var mv = MiscValues.FromPayloads(
|
||||
corePayload: new byte[140], // 4 + 136
|
||||
extendedPayload: TestData.WithHeader(new byte[n]));
|
||||
|
||||
Assert.Equal(n, mv.Extended.Length);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user