Skip to content

Commit

Permalink
Upgrade to NUnit 4, Serilog 6 (and some code cleanup)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed Jul 7, 2024
1 parent 2400f67 commit 3ba3fde
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/ZWaveDotNet/obj
/UnitTests/bin/Debug/net6.0
/UnitTests/obj
/UnitTests/bin/Release/net6.0
4 changes: 2 additions & 2 deletions TestConsole/ExampleConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TestConsole/TestConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TestConsole
private static readonly HashSet<ushort> InterviewList = new HashSet<ushort>();
private static readonly HashSet<ushort> ReadyList = new HashSet<ushort>();
private static RFRegion region = RFRegion.Unknown;
private static LinkedList<string> Reports = new LinkedList<string>();
private static readonly LinkedList<string> Reports = new LinkedList<string>();
private enum Mode { Display, Inclusion, Exclusion};
private static Mode currentMode = Mode.Display;

Expand Down
12 changes: 6 additions & 6 deletions UnitTests/CMAC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class CMAC
public void Test1()
{
Memory<byte> key = MemoryUtil.From("2B7E151628AED2A6ABF7158809CF4F3C");
Memory<byte> plaintext = new byte[0];
Memory<byte> plaintext = Array.Empty<byte>();
Memory<byte> expected = MemoryUtil.From("BB1D6929E95937287FA37D129B756746");
var result = AES.ComputeCMAC(key.ToArray(), plaintext);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}

[Test]
Expand All @@ -24,7 +24,7 @@ public void Test2()
Memory<byte> plaintext = MemoryUtil.From("6BC1BEE22E409F96E93D7E117393172A");
Memory<byte> expected = MemoryUtil.From("070A16B46B4D4144F79BDD9DD04A287C");
var result = AES.ComputeCMAC(key.ToArray(), plaintext);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}

[Test]
Expand All @@ -34,7 +34,7 @@ public void Test3()
Memory<byte> plaintext = MemoryUtil.From("6BC1BEE22E409F96E93D7E117393172AAE2D8A57");
Memory<byte> expected = MemoryUtil.From("7D85449EA6EA19C823A7BF78837DFADE");
var result = AES.ComputeCMAC(key.ToArray(), plaintext);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}

[Test]
Expand All @@ -44,7 +44,7 @@ public void Test4()
Memory<byte> plaintext = MemoryUtil.From("6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411");
Memory<byte> expected = MemoryUtil.From("dfa66747de9ae63030ca32611497c827");
var result = AES.ComputeCMAC(key.ToArray(), plaintext);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}

[Test]
Expand All @@ -54,7 +54,7 @@ public void Test5()
Memory<byte> plaintext = MemoryUtil.From("6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710");
Memory<byte> expected = MemoryUtil.From("51F0BEBF7E3B9D92FC49741779363CFE");
var result = AES.ComputeCMAC(key.ToArray(), plaintext);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}
}
}
2 changes: 1 addition & 1 deletion UnitTests/CRC-CCITT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Test1()
Memory<byte> expected = MemoryUtil.From("2C66");
CRC16_CCITT crc = new CRC16_CCITT();
byte[] result = crc.ComputeChecksum(payload);
CollectionAssert.AreEqual(result, expected.ToArray());
Assert.That(expected.ToArray(), Is.EqualTo(result).AsCollection);
}
}
}
10 changes: 5 additions & 5 deletions UnitTests/CTR_DRBG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Test1()

//Generate and Print
var final_result = CTR_DRBG.Generate(working_state, 64);
CollectionAssert.AreEqual(final_result.output.ToArray(), MemoryUtil.From("f80111d08e874672f32f42997133a5210f7a9375e22cea70587f9cfafebe0f6a6aa2eb68e7dd9164536d53fa020fcab20f54caddfab7d6d91e5ffec1dfd8deaa").ToArray());
Assert.That(final_result.output.ToArray(), Is.EqualTo(MemoryUtil.From("f80111d08e874672f32f42997133a5210f7a9375e22cea70587f9cfafebe0f6a6aa2eb68e7dd9164536d53fa020fcab20f54caddfab7d6d91e5ffec1dfd8deaa").ToArray()).AsCollection);
}

[Test]
Expand All @@ -45,7 +45,7 @@ public void Test2()

//Generate and Print
var final_result = CTR_DRBG.Generate(working_state, 64);
CollectionAssert.AreEqual(final_result.output.ToArray(), MemoryUtil.From("2915c9fabfbf7c62d68d83b4e65a239885e809ceac97eb8ef4b64df59881c277d3a15e0e15b01d167c49038fad2f54785ea714366d17bb2f8239fd217d7e1cba").ToArray());
Assert.That(final_result.output.ToArray(), Is.EqualTo(MemoryUtil.From("2915c9fabfbf7c62d68d83b4e65a239885e809ceac97eb8ef4b64df59881c277d3a15e0e15b01d167c49038fad2f54785ea714366d17bb2f8239fd217d7e1cba").ToArray()).AsCollection);
}

[Test]
Expand All @@ -65,7 +65,7 @@ public void Test3()

//Generate and Print
var final_result = CTR_DRBG.Generate(working_state, 64);
CollectionAssert.AreEqual(final_result.output.ToArray(), MemoryUtil.From("52f5e718bf48d99e498775c00378e545799bb2059aef0b74be573d8283f02b5293917913bc8f26fc23760a1c86c3f5c844857419868eafeb17c9248227d026b8").ToArray());
Assert.That(final_result.output.ToArray(), Is.EqualTo(MemoryUtil.From("52f5e718bf48d99e498775c00378e545799bb2059aef0b74be573d8283f02b5293917913bc8f26fc23760a1c86c3f5c844857419868eafeb17c9248227d026b8").ToArray()).AsCollection);
}

[Test]
Expand All @@ -85,7 +85,7 @@ public void Test4()

//Generate and Print
var final_result = CTR_DRBG.Generate(working_state, 64);
CollectionAssert.AreEqual(final_result.output.ToArray(), MemoryUtil.From("96eee34e4cfc905be64cf1dc64c6e07f1ceb3bdb745f42332568873b80b11f1a1ac6d0d576afefcdd7c70ce6a882ee940463323b51c1633998a809003b947210").ToArray());
Assert.That(final_result.output.ToArray(), Is.EqualTo(MemoryUtil.From("96eee34e4cfc905be64cf1dc64c6e07f1ceb3bdb745f42332568873b80b11f1a1ac6d0d576afefcdd7c70ce6a882ee940463323b51c1633998a809003b947210").ToArray()).AsCollection);
}

[Test]
Expand All @@ -105,7 +105,7 @@ public void Test5()

//Generate and Print
var final_result = CTR_DRBG.Generate(working_state, 64);
CollectionAssert.AreEqual(final_result.output.ToArray(), MemoryUtil.From("f6040af8ae7ab04cde02be25af95dedada3b10321c418c7af4ed5bc82e28ebf778ae4248c565292e4cb8eccd40f18a382848b40d7441a291cc9ee8465cbe5fd6").ToArray());
Assert.That(final_result.output.ToArray(), Is.EqualTo(MemoryUtil.From("f6040af8ae7ab04cde02be25af95dedada3b10321c418c7af4ed5bc82e28ebf778ae4248c565292e4cb8eccd40f18a382848b40d7441a291cc9ee8465cbe5fd6").ToArray()).AsCollection);
}
}
}
2 changes: 1 addition & 1 deletion UnitTests/QRCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Test1()
Assert.That(parser.Version, Is.EqualTo(0x1));
Assert.That(parser.Keys, Is.EqualTo((SecurityKey.S2Authenticated | SecurityKey.S2Unauthenticated)));
});
CollectionAssert.AreEqual(DSK.ToArray(), parser.DSK.ToArray());
Assert.That(DSK.ToArray(), Is.EqualTo(parser.DSK.ToArray()).AsCollection);
}
}
}
6 changes: 3 additions & 3 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.10.0">
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion ZWaveDotNet/CommandClassReports/EndPointFindReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public EndPointFindReport(Memory<byte> payload)
EndPointIDs[i - 3] = (byte)(payload.Span[i] & 0x7F);
}
else
EndPointIDs = new byte[0];
EndPointIDs = Array.Empty<byte>();
}
}
}
2 changes: 1 addition & 1 deletion ZWaveDotNet/CommandClassReports/ICommandClassReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
public interface ICommandClassReport
{
public string ToString();
public string? ToString();
}
}
4 changes: 1 addition & 3 deletions ZWaveDotNet/CommandClasses/SceneActuatorConf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ namespace ZWaveDotNet.CommandClasses
{
[CCVersion(CommandClass.SceneActuatorConf)]
public class SceneActuatorConf : CommandClassBase
{
public event CommandClassEvent? Report;

{
enum SceneActuatorConfCommand : byte
{
Set = 0x01,
Expand Down
4 changes: 1 addition & 3 deletions ZWaveDotNet/CommandClasses/TimeParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace ZWaveDotNet.CommandClasses
{
[CCVersion(CommandClass.TimeParams)]
public class TimeParameters : CommandClassBase
{
public event CommandClassEvent? Report;

{
enum TimeParamCommand : byte
{
Set = 0x01,
Expand Down
4 changes: 2 additions & 2 deletions ZWaveDotNet/ZWaveDotNet.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
</ItemGroup>

</Project>

0 comments on commit 3ba3fde

Please sign in to comment.