mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
Merge pull request #280 from mycroes/develop
Tests/TypeTests: Add ClassTests from #178
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
<Compile Include="S7NetTestsSync.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\TestLongStruct.cs" />
|
||||
<Compile Include="TypeTests\ClassTests.cs" />
|
||||
<Compile Include="TypeTests\DateTimeTests.cs" />
|
||||
<Compile Include="TypeTests\StringExTests.cs" />
|
||||
<Compile Include="TypeTests\StringTests.cs" />
|
||||
|
||||
33
S7.Net.UnitTest/TypeTests/ClassTests.cs
Normal file
33
S7.Net.UnitTest/TypeTests/ClassTests.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using S7.Net.Types;
|
||||
|
||||
namespace S7.Net.UnitTest.TypeTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClassTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void GetClassSizeTest()
|
||||
{
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(1, 1)), 6);
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(2, 15)), 6);
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(2, 16)), 6);
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(2, 17)), 8);
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(3, 15)), 8);
|
||||
Assert.AreEqual(Class.GetClassSize(new TestClassUnevenSize(3, 17)), 10);
|
||||
}
|
||||
|
||||
private class TestClassUnevenSize
|
||||
{
|
||||
public bool Bool { get; set; }
|
||||
public byte[] Bytes { get; set; }
|
||||
public bool[] Bools { get; set; }
|
||||
|
||||
public TestClassUnevenSize(int byteCount, int bitCount)
|
||||
{
|
||||
Bytes = new byte[byteCount];
|
||||
Bools = new bool[bitCount];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user