Added test structure

This commit is contained in:
Felix Weiß
2023-02-27 16:01:47 +01:00
parent 43c7f72ac4
commit fb2bd8d56d
4 changed files with 124 additions and 18 deletions

View 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>

View 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());
}
}
}
}