mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Added test structure
This commit is contained in:
28
MewtocolTests/MewtocolTests.csproj
Normal file
28
MewtocolTests/MewtocolTests.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MewtocolNet\MewtocolNet.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
55
MewtocolTests/TestComProtocol.cs
Normal file
55
MewtocolTests/TestComProtocol.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Xunit;
|
||||
|
||||
using MewtocolNet;
|
||||
using MewtocolNet.Registers;
|
||||
using System.Diagnostics;
|
||||
using Xunit.Abstractions;
|
||||
using System.Collections;
|
||||
|
||||
namespace MewtocolTests {
|
||||
|
||||
public class TestComProtocol {
|
||||
|
||||
private readonly ITestOutputHelper output;
|
||||
|
||||
public TestComProtocol (ITestOutputHelper output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Numeric register protocol identifiers")]
|
||||
public void NumericRegisterMewtocolIdentifiers () {
|
||||
|
||||
List<Register> registers = new List<Register> {
|
||||
new NRegister<short>(50),
|
||||
new NRegister<ushort>(50),
|
||||
new NRegister<int>(50),
|
||||
new NRegister<uint>(50),
|
||||
new NRegister<float>(50),
|
||||
new NRegister<BitArray>(50),
|
||||
};
|
||||
|
||||
List<string> expcectedIdents = new List<string> {
|
||||
"D0005000050", //single word register
|
||||
"D0005000050", //single word register
|
||||
"D0005000051", //double word register
|
||||
"D0005000051", //double word register
|
||||
"D0005000051", //double word register
|
||||
"D0005000051", //double word register
|
||||
"D0005000051", //double word register
|
||||
};
|
||||
|
||||
//test mewtocol idents
|
||||
for (int i = 0; i < registers.Count; i++) {
|
||||
|
||||
Register? reg = registers[i];
|
||||
string expect = expcectedIdents[i];
|
||||
|
||||
Assert.Equal(expect, reg.BuildMewtocolIdent());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user