Add unit test for ReadClass uint32 bug.

https://github.com/S7NetPlus/s7netplus/issues/414
This commit is contained in:
Serge Camille
2021-10-04 18:53:13 +02:00
parent b475aee2e7
commit 8df1a9c8cb

View File

@@ -17,6 +17,19 @@ namespace S7.Net.UnitTest.TypeTests
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(3, 17)), 10);
}
/// <summary>
/// Ensure Uint32 is correctly parsed through ReadClass functions. Adresses issue https://github.com/S7NetPlus/s7netplus/issues/414
/// </summary>
[TestMethod]
public void TestUint32Read()
{
var result = new TestUint32();
var data = new byte[4] { 0, 0, 0, 5 };
var bytesRead = Class.FromBytes(result, data);
Assert.AreEqual(bytesRead, data.Length);
Assert.AreEqual(5u, result.Value1);
}
private class TestClassUnevenSize
{
public bool Bool { get; set; }
@@ -29,5 +42,10 @@ namespace S7.Net.UnitTest.TypeTests
Bools = new bool[bitCount];
}
}
private class TestUint32
{
public uint Value1 { get; set; }
}
}
}