diff --git a/Directory.Packages.props b/Directory.Packages.props index 04f9831..385929e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,6 +26,7 @@ + diff --git a/Meshtastic.IntegrationTest/Meshtastic.IntegrationTest.csproj b/Meshtastic.IntegrationTest/Meshtastic.IntegrationTest.csproj index ac61ff8..51a1b0d 100644 --- a/Meshtastic.IntegrationTest/Meshtastic.IntegrationTest.csproj +++ b/Meshtastic.IntegrationTest/Meshtastic.IntegrationTest.csproj @@ -7,7 +7,6 @@ - @@ -17,6 +16,7 @@ + diff --git a/Meshtastic.IntegrationTest/Tests/ConnectedDeviceTests/TextMessageTests.cs b/Meshtastic.IntegrationTest/Tests/ConnectedDeviceTests/TextMessageTests.cs index c9d0f3c..a1924df 100644 --- a/Meshtastic.IntegrationTest/Tests/ConnectedDeviceTests/TextMessageTests.cs +++ b/Meshtastic.IntegrationTest/Tests/ConnectedDeviceTests/TextMessageTests.cs @@ -42,9 +42,9 @@ public async Task SendTextMessage_ShouldReceiveAck_WhenDeviceConnected(Meshtasti return await Task.FromResult(container.MyNodeInfo.MyNodeNum != 0); }); - container.Should().NotBeNull(); - container.MyNodeInfo.Should().NotBeNull(); - container.MyNodeInfo.MyNodeNum.Should().NotBe(0u); + container.ShouldNotBeNull(); + container.MyNodeInfo.ShouldNotBeNull(); + container.MyNodeInfo.MyNodeNum.ShouldNotBe(0u); _logger.LogInformation($"Connected to device. Node number: {container.MyNodeInfo.MyNodeNum}"); @@ -88,8 +88,8 @@ await connection.WriteToRadio(toRadioFactory.CreateMeshPacketMessage(textMessage } // Assert - ackReceived.Should().BeTrue("An ACK should be received for the sent message"); - errorReason.Should().Be(Routing.Types.Error.None, "The message should be delivered without errors"); + ackReceived.ShouldBeTrue("An ACK should be received for the sent message"); + errorReason.ShouldBe(Routing.Types.Error.None, "The message should be delivered without errors"); } [Test] @@ -124,14 +124,14 @@ public async Task GetDeviceInfo_ShouldReturnValidNodeInfo(MeshtasticDevice devic } // Assert - container.Should().NotBeNull(); - container!.MyNodeInfo.Should().NotBeNull(); - container.MyNodeInfo.MyNodeNum.Should().NotBe(0u); + container.ShouldNotBeNull(); + container!.MyNodeInfo.ShouldNotBeNull(); + container.MyNodeInfo.MyNodeNum.ShouldNotBe(0u); var deviceNode = container.GetDeviceNodeInfo(); - deviceNode.Should().NotBeNull(); - deviceNode!.User.Should().NotBeNull(); - deviceNode.User!.LongName.Should().NotBeNullOrEmpty(); + deviceNode.ShouldNotBeNull(); + deviceNode!.User.ShouldNotBeNull(); + deviceNode.User!.LongName.ShouldNotBeNullOrEmpty(); _logger.LogInformation($"Device Info - Node: {container.MyNodeInfo.MyNodeNum}, " + $"Name: '{deviceNode.User.LongName}', " + diff --git a/Meshtastic.IntegrationTest/Usings.cs b/Meshtastic.IntegrationTest/Usings.cs index 10a7cd3..e40fef9 100644 --- a/Meshtastic.IntegrationTest/Usings.cs +++ b/Meshtastic.IntegrationTest/Usings.cs @@ -1,5 +1,5 @@ global using NUnit.Framework; -global using FluentAssertions; +global using Shouldly; global using Microsoft.Extensions.Logging; global using Meshtastic.Connections; global using Meshtastic.Data; diff --git a/Meshtastic.Test/CommandHandlers/CommandHandlerTests.cs b/Meshtastic.Test/CommandHandlers/CommandHandlerTests.cs index 194ad1f..b4af062 100644 --- a/Meshtastic.Test/CommandHandlers/CommandHandlerTests.cs +++ b/Meshtastic.Test/CommandHandlers/CommandHandlerTests.cs @@ -43,8 +43,7 @@ public async Task MetadataCommandHandler_Should_ReceiveMetadataResponse() ReceivedWantConfigPayloads(); InformationLogsContain("Getting device metadata"); - container.FromRadioMessageLog.Should() - .Contain(fromRadio => fromRadio.GetPayload() != null && + container.FromRadioMessageLog.ShouldContain(fromRadio => fromRadio.GetPayload() != null && fromRadio.GetPayload()!.GetDeviceMetadataResponse != null); } @@ -66,7 +65,7 @@ public void GetCommandHandler_Should_RejectBadSettings() { var settings = new List() { "butt.farts" }; var handler = new GetCommandHandler(settings, ConnectionContext, CommandContext); - handler.ParsedSettings.Should().BeNull(); + handler.ParsedSettings.ShouldBeNull(); } [Test] @@ -78,7 +77,7 @@ public async Task SetCommandHandler_Should_SetValues() await handler.Handle(); var container = await new InfoCommandHandler(ConnectionContext, CommandContext).Handle(); - container.LocalConfig.Display.ScreenOnSecs.Should().Be(123456); + container.LocalConfig.Display.ScreenOnSecs.ShouldBe((uint)123456); } [Test] @@ -87,7 +86,7 @@ public void SetCommandHandler_Should_RejectBadSettings() { var settings = new List() { "butt.farts=2" }; var handler = new SetCommandHandler(settings, ConnectionContext, CommandContext); - handler.ParsedSettings.Should().BeNull(); + handler.ParsedSettings.ShouldBeNull(); } // [Test] @@ -99,7 +98,7 @@ public void SetCommandHandler_Should_RejectBadSettings() // InformationLogsContain("Sending position to device"); // InformationLogsContain("Setting Position.FixedPosition to True"); // var routingPacket = container.FromRadioMessageLog.First(fromRadio => fromRadio.GetPayload() != null); - // routingPacket.GetPayload()!.ErrorReason.Should().Be(Routing.Types.Error.None); + // routingPacket.GetPayload()!.ErrorReason.ShouldBe(Routing.Types.Error.None); // } [Test] @@ -111,9 +110,9 @@ public async Task ChannelCommandHandler_Should_SavePrimaryChannel() var container = await handler.Handle(); InformationLogsContain("Writing channel"); var routingPacket = container.FromRadioMessageLog.First(fromRadio => fromRadio.GetPayload() != null); - routingPacket.GetPayload()!.ErrorReason.Should().Be(Routing.Types.Error.None); + routingPacket.GetPayload()!.ErrorReason.ShouldBe(Routing.Types.Error.None); var adminMessages = container.ToRadioMessageLog.Where(toRadio => toRadio?.Packet?.Decoded.Portnum == PortNum.AdminApp); - adminMessages.Should().Contain(adminMessage => + adminMessages.ShouldContain(adminMessage => AdminMessage.Parser.ParseFrom(adminMessage.Packet.Decoded.Payload).PayloadVariantCase == AdminMessage.PayloadVariantOneofCase.SetChannel); } @@ -126,9 +125,9 @@ public async Task ChannelCommandHandler_Should_SavePrimaryChannelWithNoPsk() var container = await handler.Handle(); InformationLogsContain("Writing channel"); var routingPacket = container.FromRadioMessageLog.First(fromRadio => fromRadio.GetPayload() != null); - routingPacket.GetPayload()!.ErrorReason.Should().Be(Routing.Types.Error.None); + routingPacket.GetPayload()!.ErrorReason.ShouldBe(Routing.Types.Error.None); var adminMessages = container.ToRadioMessageLog.Where(toRadio => toRadio?.Packet?.Decoded.Portnum == PortNum.AdminApp); - adminMessages.Should().Contain(adminMessage => + adminMessages.ShouldContain(adminMessage => AdminMessage.Parser.ParseFrom(adminMessage.Packet.Decoded.Payload).PayloadVariantCase == AdminMessage.PayloadVariantOneofCase.SetChannel); } @@ -141,9 +140,9 @@ public async Task ChannelCommandHandler_Should_SavePrimaryChannelWithPsk() var container = await handler.Handle(); InformationLogsContain("Writing channel"); var routingPacket = container.FromRadioMessageLog.First(fromRadio => fromRadio.GetPayload() != null); - routingPacket.GetPayload()!.ErrorReason.Should().Be(Routing.Types.Error.None); + routingPacket.GetPayload()!.ErrorReason.ShouldBe(Routing.Types.Error.None); var adminMessages = container.ToRadioMessageLog.Where(toRadio => toRadio?.Packet?.Decoded.Portnum == PortNum.AdminApp); - adminMessages.Should().Contain(adminMessage => + adminMessages.ShouldContain(adminMessage => AdminMessage.Parser.ParseFrom(adminMessage.Packet.Decoded.Payload).PayloadVariantCase == AdminMessage.PayloadVariantOneofCase.SetChannel); } @@ -156,9 +155,9 @@ public async Task ChannelCommandHandler_Should_AllowEnableOfSecondary() var container = await handler.Handle(); InformationLogsContain("Writing channel"); var routingPacket = container.FromRadioMessageLog.First(fromRadio => fromRadio.GetPayload() != null); - routingPacket.GetPayload()!.ErrorReason.Should().Be(Routing.Types.Error.None); + routingPacket.GetPayload()!.ErrorReason.ShouldBe(Routing.Types.Error.None); var adminMessages = container.ToRadioMessageLog.Where(toRadio => toRadio?.Packet?.Decoded.Portnum == PortNum.AdminApp); - adminMessages.Should().Contain(adminMessage => + adminMessages.ShouldContain(adminMessage => AdminMessage.Parser.ParseFrom(adminMessage.Packet.Decoded.Payload).PayloadVariantCase == AdminMessage.PayloadVariantOneofCase.SetChannel); } @@ -169,6 +168,6 @@ public async Task ChannelCommandHandler_Should_ThrowExceptionForOutOfRangeIndex( var channelSettings = new ChannelOperationSettings(ChannelOperation.Save, 10, null, null, null, null, null); var handler = new ChannelCommandHandler(channelSettings, ConnectionContext, CommandContext); var action = () => handler.Handle(); - await action.Should().ThrowAsync(); + await action.ShouldThrowAsync(); } } \ No newline at end of file diff --git a/Meshtastic.Test/Commands/CannedMessagesCommandTests.cs b/Meshtastic.Test/Commands/CannedMessagesCommandTests.cs index d388a7f..65a7fb0 100644 --- a/Meshtastic.Test/Commands/CannedMessagesCommandTests.cs +++ b/Meshtastic.Test/Commands/CannedMessagesCommandTests.cs @@ -20,29 +20,29 @@ public void Setup() public async Task CannedMessagesCommand_Should_Fail_ForEmptyOrNullMessagesOnSet() { var result = await rootCommand.InvokeAsync("canned-messages set --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Must specify pipe delimited messages"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Must specify pipe delimited messages"); } [Test] public async Task CannedMessagesCommand_Should_Fail_ForPipelessMessagesOnSet() { var result = await rootCommand.InvokeAsync("canned-messages set hello --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Must specify pipe delimited messages"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Must specify pipe delimited messages"); } [Test] public async Task CannedMessagesCommand_Should_Succeed_ForValidGet() { var result = await rootCommand.InvokeAsync("canned-messages get --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } [Test] public async Task CannedMessagesCommand_Should_Succeed_ForValidSet() { var result = await rootCommand.InvokeAsync("canned-messages set \"I need an alpinist|Halp\" --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/ChannelCommandTests.cs b/Meshtastic.Test/Commands/ChannelCommandTests.cs index 8c21be2..c65e5da 100644 --- a/Meshtastic.Test/Commands/ChannelCommandTests.cs +++ b/Meshtastic.Test/Commands/ChannelCommandTests.cs @@ -20,25 +20,25 @@ public void Setup() public async Task ChannelCommand_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("channel save --index 0 --name \"Derp\"s --port SIMPORT", Console); - result.Should().BeGreaterThan(0); + result.ShouldBeGreaterThan(0); } [Test] public async Task ChannelCommand_Should_Fail_ForIndexOutOfRange() { var result = await rootCommand.InvokeAsync("channel disable --index 10 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Channel index is out of range"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Channel index is out of range"); } [Test] public async Task ChannelCommand_Should_Fail_ForEnable_DisablePrimary() { var result = await rootCommand.InvokeAsync("channel disable --index 0 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Cannot enable / disable PRIMARY channel"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Cannot enable / disable PRIMARY channel"); result = await rootCommand.InvokeAsync("channel enable --index 0 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Cannot enable / disable PRIMARY channel"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Cannot enable / disable PRIMARY channel"); } } diff --git a/Meshtastic.Test/Commands/FactoryResetCommandTests.cs b/Meshtastic.Test/Commands/FactoryResetCommandTests.cs index e57d9e3..89bd8b9 100644 --- a/Meshtastic.Test/Commands/FactoryResetCommandTests.cs +++ b/Meshtastic.Test/Commands/FactoryResetCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task FactoryReset_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("factory-reset --port SIMPORT", Console); - result.Should().BeGreaterThan(0); + result.ShouldBeGreaterThan(0); } } diff --git a/Meshtastic.Test/Commands/FileCommandTests.cs b/Meshtastic.Test/Commands/FileCommandTests.cs index 55f2141..72b71fc 100644 --- a/Meshtastic.Test/Commands/FileCommandTests.cs +++ b/Meshtastic.Test/Commands/FileCommandTests.cs @@ -20,14 +20,14 @@ public void Setup() public async Task FileCommand_Should_Fail_ForEmptyOrNullText() { var result = await rootCommand.InvokeAsync("file --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Required argument missing for command: 'file'"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Required argument missing for command: 'file'"); } [Test] public async Task FileCommand_Should_Succeed_ForValidText() { var result = await rootCommand.InvokeAsync("file 'Butt.txt' --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/FixedPositionCommandTests.cs b/Meshtastic.Test/Commands/FixedPositionCommandTests.cs index f9979bc..5d571f5 100644 --- a/Meshtastic.Test/Commands/FixedPositionCommandTests.cs +++ b/Meshtastic.Test/Commands/FixedPositionCommandTests.cs @@ -20,28 +20,28 @@ public void Setup() public async Task FixedPositionCommand_Should_Fail_ForInvalidLat() { var result = await rootCommand.InvokeAsync("fixed-position -91 -90.023 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid latitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid latitude"); result = await rootCommand.InvokeAsync("fixed-position 91 -90.023 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid latitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid latitude"); } [Test] public async Task FixedPositionCommand_Should_Fail_ForInvalidLon() { var result = await rootCommand.InvokeAsync("fixed-position 34.00 -181 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid longitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid longitude"); result = await rootCommand.InvokeAsync("fixed-position 34.00 -181 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid longitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid longitude"); } [Test] public async Task FixedPositionCommand_Should_Succeed_ForValidCoords() { var result = await rootCommand.InvokeAsync("fixed-position 34.00 -90 --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/GetCommandTests.cs b/Meshtastic.Test/Commands/GetCommandTests.cs index 0c3fd5d..282195b 100644 --- a/Meshtastic.Test/Commands/GetCommandTests.cs +++ b/Meshtastic.Test/Commands/GetCommandTests.cs @@ -29,14 +29,14 @@ public void Setup() public async Task SetCommand_Should_Fail_ForEmptyOrNullSettings() { var result = await rootCommand.InvokeAsync("get --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Option '--setting' is required"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Option '--setting' is required"); } [Test] public async Task GetCommand_Should_Succeed_ForValidSetting() { var result = await rootCommand.InvokeAsync("get --setting Mqtt.Address --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/InfoCommandTests.cs b/Meshtastic.Test/Commands/InfoCommandTests.cs index 0c8c601..060bb03 100644 --- a/Meshtastic.Test/Commands/InfoCommandTests.cs +++ b/Meshtastic.Test/Commands/InfoCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task InfoCommand_Should_Succeed_ForValidCoords() { var result = await rootCommand.InvokeAsync("info --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/ListCommandTests.cs b/Meshtastic.Test/Commands/ListCommandTests.cs index 7531ae8..b8184e8 100644 --- a/Meshtastic.Test/Commands/ListCommandTests.cs +++ b/Meshtastic.Test/Commands/ListCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task ListCommand_Should_Succeed_ForValidCoords() { var result = await rootCommand.InvokeAsync("list --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/MetadataCommandTests.cs b/Meshtastic.Test/Commands/MetadataCommandTests.cs index eef96c9..f3d9ce4 100644 --- a/Meshtastic.Test/Commands/MetadataCommandTests.cs +++ b/Meshtastic.Test/Commands/MetadataCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task MetadataCommand_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("metadata --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/RebootCommandTests.cs b/Meshtastic.Test/Commands/RebootCommandTests.cs index 4a808ad..3c234b6 100644 --- a/Meshtastic.Test/Commands/RebootCommandTests.cs +++ b/Meshtastic.Test/Commands/RebootCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task RebootCommand_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("reboot --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/ResetNodeDbCommandTests.cs b/Meshtastic.Test/Commands/ResetNodeDbCommandTests.cs index 719a7fc..ad05563 100644 --- a/Meshtastic.Test/Commands/ResetNodeDbCommandTests.cs +++ b/Meshtastic.Test/Commands/ResetNodeDbCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task ResetNodeDbCommand_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("reset-nodedb --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/SendInputEventCommandTests.cs b/Meshtastic.Test/Commands/SendInputEventCommandTests.cs index a5b8afa..61ec1b0 100644 --- a/Meshtastic.Test/Commands/SendInputEventCommandTests.cs +++ b/Meshtastic.Test/Commands/SendInputEventCommandTests.cs @@ -20,21 +20,21 @@ public void Setup() public async Task SendInputEventCommand_Should_Fail_ForMissingEventCode() { var result = await rootCommand.InvokeAsync("input-event --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Required argument missing for command: 'input-event'"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Required argument missing for command: 'input-event'"); } [Test] public async Task SendInputEventCommand_Should_Succeed_ForValidEventCode() { var result = await rootCommand.InvokeAsync("input-event 1 --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } [Test] public async Task SendInputEventCommand_Should_Succeed_WithAllOptions() { var result = await rootCommand.InvokeAsync("input-event 1 --kb-char 65 --touch-x 100 --touch-y 200 --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/SendTextCommandTests.cs b/Meshtastic.Test/Commands/SendTextCommandTests.cs index 30eb0c2..0bf0570 100644 --- a/Meshtastic.Test/Commands/SendTextCommandTests.cs +++ b/Meshtastic.Test/Commands/SendTextCommandTests.cs @@ -20,14 +20,14 @@ public void Setup() public async Task SendTextCommand_Should_Fail_ForEmptyOrNullText() { var result = await rootCommand.InvokeAsync("text --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Required argument missing for command: 'text'"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Required argument missing for command: 'text'"); } [Test] public async Task SendTextCommand_Should_Succeed_ForValidText() { var result = await rootCommand.InvokeAsync("text 'Butt' --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/SendWaypointCommandTests.cs b/Meshtastic.Test/Commands/SendWaypointCommandTests.cs index eb56588..0e32d9a 100644 --- a/Meshtastic.Test/Commands/SendWaypointCommandTests.cs +++ b/Meshtastic.Test/Commands/SendWaypointCommandTests.cs @@ -20,28 +20,28 @@ public void Setup() public async Task SendWaypointCommand_Should_Fail_ForInvalidLat() { var result = await rootCommand.InvokeAsync("waypoint -91 -90.023 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid latitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid latitude"); result = await rootCommand.InvokeAsync("waypoint 91 -90.023 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid latitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid latitude"); } [Test] public async Task SendWaypointCommand_Should_Fail_ForInvalidLon() { var result = await rootCommand.InvokeAsync("waypoint 34.00 -181 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid longitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid longitude"); result = await rootCommand.InvokeAsync("waypoint 34.00 -181 --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Invalid longitude"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Invalid longitude"); } [Test] public async Task SendWaypointCommand_Should_Succeed_ForValidCoords() { var result = await rootCommand.InvokeAsync("waypoint 34.00 -90 --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/SetCommandTests.cs b/Meshtastic.Test/Commands/SetCommandTests.cs index b849145..d6b0200 100644 --- a/Meshtastic.Test/Commands/SetCommandTests.cs +++ b/Meshtastic.Test/Commands/SetCommandTests.cs @@ -29,14 +29,14 @@ public void Setup() public async Task SetCommand_Should_Fail_ForEmptyOrNullSettings() { var result = await rootCommand.InvokeAsync("set --port SIMPORT", Console); - result.Should().BeGreaterThan(0); - Out.Output.Should().Contain("Option '--setting' is required"); + result.ShouldBeGreaterThan(0); + Out.Output.ShouldContain("Option '--setting' is required"); } [Test] public async Task SetCommand_Should_Succeed_ForValidSetting() { var result = await rootCommand.InvokeAsync("set --setting Mqtt.Address=yourmom.com --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/TraceRouteCommandTests.cs b/Meshtastic.Test/Commands/TraceRouteCommandTests.cs index 627dc7a..bb55137 100644 --- a/Meshtastic.Test/Commands/TraceRouteCommandTests.cs +++ b/Meshtastic.Test/Commands/TraceRouteCommandTests.cs @@ -20,6 +20,6 @@ public void Setup() public async Task TraceRouteCommand_Should_Succeed_ForValidArgs() { var result = await rootCommand.InvokeAsync("traceroute --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Commands/UrlCommandTests.cs b/Meshtastic.Test/Commands/UrlCommandTests.cs index 90a6143..020cef6 100644 --- a/Meshtastic.Test/Commands/UrlCommandTests.cs +++ b/Meshtastic.Test/Commands/UrlCommandTests.cs @@ -20,13 +20,13 @@ public void Setup() public async Task UrlCommand_Should_Succeed_ForValidSetArgs() { var result = await rootCommand.InvokeAsync("url get --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } [Test] public async Task UrlCommand_Should_Succeed_ForValidGetArgs() { var result = await rootCommand.InvokeAsync("url set http://meshtastic.org/#e/1235 --port SIMPORT", Console); - result.Should().Be(0); + result.ShouldBe(0); } } diff --git a/Meshtastic.Test/Crypto/PKIEncryptionTests.cs b/Meshtastic.Test/Crypto/PKIEncryptionTests.cs index 4861603..cb13411 100644 --- a/Meshtastic.Test/Crypto/PKIEncryptionTests.cs +++ b/Meshtastic.Test/Crypto/PKIEncryptionTests.cs @@ -19,14 +19,14 @@ public void TestRealLifeDecryption() var senderPublicKey = Convert.FromBase64String("WWb1Pvgu6zs1dnncqtMcLW6AvFo84U9pJfJp417i+T4="); var meshPacket = MeshPacket.Parser.ParseFrom(rawCapturedPacket); - meshPacket.Decoded.Should().BeNull(); - meshPacket.Encrypted.Should().NotBeNull(); + meshPacket.Decoded.ShouldBeNull(); + meshPacket.Encrypted.ShouldNotBeNull(); PKIEncryption.Decrypt(recipientPrivateKey, senderPublicKey, meshPacket); - meshPacket.Decoded.Should().NotBeNull(); - meshPacket.Encrypted.Should().BeNullOrEmpty(); + meshPacket.Decoded.ShouldNotBeNull(); + (meshPacket.Encrypted?.Length ?? 0).ShouldBe(0); var plaintext = Encoding.UTF8.GetString(meshPacket.Decoded.Payload.ToArray()); - plaintext.Should().Be("Test packet for PKI, please ignore"); + plaintext.ShouldBe("Test packet for PKI, please ignore"); } [Test] @@ -45,22 +45,22 @@ public void EncryptDecryptRoundTrip() } }; - senderMeshPacket.Decoded.Should().NotBeNull(); - senderMeshPacket.Encrypted.Should().BeNullOrEmpty(); - PKIEncryption.Encrypt(senderKeyPair.privateKey, recipientKeyPair.publicKey, senderMeshPacket); - senderMeshPacket.Decoded.Should().BeNull(); - senderMeshPacket.Encrypted.Should().NotBeNull(); + senderMeshPacket.Decoded.ShouldNotBeNull(); + (senderMeshPacket.Encrypted?.Length ?? 0).ShouldBe(0); + PKIEncryption.Encrypt(senderKeyPair.privateKey, recipientKeyPair.publicKey, senderMeshPacket); + senderMeshPacket.Decoded.ShouldBeNull(); + senderMeshPacket.Encrypted.ShouldNotBeNull(); var recipientMeshPacket = MeshPacket.Parser.ParseFrom(senderMeshPacket.ToByteArray()); - recipientMeshPacket.Decoded.Should().BeNull(); - recipientMeshPacket.Encrypted.Should().NotBeNull(); + recipientMeshPacket.Decoded.ShouldBeNull(); + recipientMeshPacket.Encrypted.ShouldNotBeNull(); PKIEncryption.Decrypt(recipientKeyPair.privateKey, senderKeyPair.publicKey, recipientMeshPacket); - recipientMeshPacket.Decoded.Should().NotBeNull(); - recipientMeshPacket.Encrypted.Should().BeNullOrEmpty(); + recipientMeshPacket.Decoded.ShouldNotBeNull(); + (recipientMeshPacket.Encrypted?.Length ?? 0).ShouldBe(0); - recipientMeshPacket.From.Should().Be(senderMeshPacket.From); - recipientMeshPacket.Id.Should().Be(senderMeshPacket.Id); - Encoding.UTF8.GetString(recipientMeshPacket.Decoded.Payload.ToByteArray()).Should().Be(plaintext); + recipientMeshPacket.From.ShouldBe(senderMeshPacket.From); + recipientMeshPacket.Id.ShouldBe(senderMeshPacket.Id); + Encoding.UTF8.GetString(recipientMeshPacket.Decoded.Payload.ToByteArray()).ShouldBe(plaintext); } } diff --git a/Meshtastic.Test/Crypto/PacketCryptoTests.cs b/Meshtastic.Test/Crypto/PacketCryptoTests.cs index 5b9ab44..9fd8849 100644 --- a/Meshtastic.Test/Crypto/PacketCryptoTests.cs +++ b/Meshtastic.Test/Crypto/PacketCryptoTests.cs @@ -18,8 +18,8 @@ public void TestDefaultKeyDecrypt() var decrypted = PacketEncryption.TransformPacket(Convert.FromBase64String("kiDV39nDDsi8AON+Czei6zUpy+F/7E+lyIpicxJR40KXBFmPkqFUEnobI5voQadha+s="), nonce, Resources.DEFAULT_PSK); var testMessage = Meshtastic.Protobufs.Data.Parser.ParseFrom(decrypted); - testMessage.Portnum.Should().Be(PortNum.NodeinfoApp); + testMessage.Portnum.ShouldBe(PortNum.NodeinfoApp); var nodeInfo = User.Parser.ParseFrom(testMessage.Payload); - nodeInfo.LongName.Should().Be("Meshtastic 65a4"); + nodeInfo.LongName.ShouldBe("Meshtastic 65a4"); } } \ No newline at end of file diff --git a/Meshtastic.Test/Data/AdminMessageFactoryTests.cs b/Meshtastic.Test/Data/AdminMessageFactoryTests.cs index 76b5fa4..370dc78 100644 --- a/Meshtastic.Test/Data/AdminMessageFactoryTests.cs +++ b/Meshtastic.Test/Data/AdminMessageFactoryTests.cs @@ -30,42 +30,42 @@ public void Setup() public void CreateBeginEditSettingsMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateBeginEditSettingsMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateCommitEditSettingsMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateCommitEditSettingsMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateRebootMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateRebootMessage(0, true); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateRebootMessage(0, false); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateSetConfigMessage_Should_ReturnValidAdminMessageMeshPacket() { var result = factory.CreateSetConfigMessage(new NetworkConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new BluetoothConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new DeviceConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new DisplayConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new LoRaConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new PositionConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetConfigMessage(new PowerConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] @@ -74,28 +74,28 @@ public void CreateSetConfigMessage_Should_ThrowArgumentException_GivenNonConfigI var instance = new Telemetry(); var action = () => factory.CreateSetConfigMessage(instance); - action.Should().Throw(); + action.ShouldThrow(); } [Test] public void CreateSetModuleConfigMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateSetModuleConfigMessage(new AudioConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new CannedMessageConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new ExternalNotificationConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new MQTTConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new RangeTestConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new SerialConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new StoreForwardConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); result = factory.CreateSetModuleConfigMessage(new TelemetryConfig()); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] @@ -104,7 +104,7 @@ public void CreateSetModuleConfigMessage_Should_ThrowArgumentException_GivenNonM var instance = new Telemetry(); var action = () => factory.CreateSetModuleConfigMessage(instance); - action.Should().Throw(); + action.ShouldThrow(); } [Test] @@ -113,42 +113,42 @@ public void CreateSetChannelMessage_Should_ReturnValidAdminMessage() var channel = new Channel(); var result = factory.CreateSetChannelMessage(channel); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateGetMetadataMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateGetMetadataMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateFactoryResetMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateFactoryResetMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateNodeDbResetMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateNodeDbResetMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateSetCannedMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateSetCannedMessage(String.Empty); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] public void CreateGetCannedMessage_Should_ReturnValidAdminMessage() { var result = factory.CreateGetCannedMessage(); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } [Test] @@ -163,6 +163,6 @@ public void CreateSendInputEventMessage_Should_ReturnValidAdminMessage() }; var result = factory.CreateSendInputEventMessage(inputEvent); - result.Decoded.Portnum.Should().Be(PortNum.AdminApp); + result.Decoded.Portnum.ShouldBe(PortNum.AdminApp); } } diff --git a/Meshtastic.Test/Data/DeviceStateContainerTests.cs b/Meshtastic.Test/Data/DeviceStateContainerTests.cs index eb1832d..a0ac6b2 100644 --- a/Meshtastic.Test/Data/DeviceStateContainerTests.cs +++ b/Meshtastic.Test/Data/DeviceStateContainerTests.cs @@ -22,7 +22,7 @@ public void AddFromRadio_Should_SetConfigSection_GivenConfig() } }; deviceStateContainer.AddFromRadio(fromRadio); - deviceStateContainer.LocalConfig.Lora.TxPower.Should().Be(100); + deviceStateContainer.LocalConfig.Lora.TxPower.ShouldBe(100); } [Test] @@ -40,7 +40,7 @@ public void AddFromRadio_Should_SetModuleConfigSection_GivenModuleConfig() } }; deviceStateContainer.AddFromRadio(fromRadio); - deviceStateContainer.LocalModuleConfig.Mqtt.Address.Should().Be("derp.com"); + deviceStateContainer.LocalModuleConfig.Mqtt.Address.ShouldBe("derp.com"); } [Test] @@ -63,7 +63,7 @@ public void AddFromRadio_Should_AddChannel_GivenNewChannel() } }; deviceStateContainer.AddFromRadio(fromRadio); - deviceStateContainer.Channels.Should().Contain(c => c.Settings.Name == "admin"); + deviceStateContainer.Channels.ShouldContain(c => c.Settings.Name == "admin"); } [Test] @@ -78,7 +78,7 @@ public void AddFromRadio_Should_SetMyInfo_GivenMyNodeInfo() } }; deviceStateContainer.AddFromRadio(fromRadio); - deviceStateContainer.MyNodeInfo.RebootCount.Should().Be(1234); + deviceStateContainer.MyNodeInfo.RebootCount.ShouldBe((uint)1234); } [Test] @@ -93,7 +93,7 @@ public void AddFromRadio_Should_AddNode_GivenNodeInfo() } }; deviceStateContainer.AddFromRadio(fromRadio); - deviceStateContainer.Nodes.Should().Contain(n => n.Num == 1234); + deviceStateContainer.Nodes.ShouldContain(n => n.Num == 1234); } [Test] @@ -101,7 +101,7 @@ public void GetAdminChannelIndex_Should_DefaultToZero() { var deviceStateContainer = new DeviceStateContainer(); var result = deviceStateContainer.GetAdminChannelIndex(); - result.Should().Be(0); + result.ShouldBe((uint)0); } [Test] @@ -118,7 +118,7 @@ public void GetAdminChannelIndex_Should_ReturnIndexOfValidAdminChannel() } }); var result = deviceStateContainer.GetAdminChannelIndex(); - result.Should().Be(3); + result.ShouldBe((uint)3); } [Test] @@ -132,7 +132,7 @@ public void GetHopLimitOrDefault_Should_DefaultToThree() } }; var result = deviceStateContainer.GetHopLimitOrDefault(); - result.Should().Be(3); + result.ShouldBe((uint)3); } [Test] @@ -144,7 +144,7 @@ public void GetHopLimitOrDefault_Should_ReturnHopLimitFromLoraConfig() Lora = new LoRaConfig() { HopLimit = 7 } }; var result = deviceStateContainer.GetHopLimitOrDefault(); - result.Should().Be(7); + result.ShouldBe((uint)7); } [Test] @@ -165,9 +165,9 @@ public void GetNodeDisplayName_Should_ReturnNumShortNameLongNameFromNodeList() }; deviceStateContainer.AddFromRadio(fromRadio); var result = deviceStateContainer.GetNodeDisplayName(1234); - result.Should().Contain("BUTT"); - result.Should().Contain("Bunghole"); - result.Should().Contain("1234"); + result.ShouldContain("BUTT"); + result.ShouldContain("Bunghole"); + result.ShouldContain("1234"); } [Test] @@ -175,6 +175,6 @@ public void GetNodeDisplayName_Should_ReturnNodeNum_WhenNodeIsntPresentInList() { var deviceStateContainer = new DeviceStateContainer(); var result = deviceStateContainer.GetNodeDisplayName(1234); - result.Should().Be("1234"); + result.ShouldBe("1234"); } } diff --git a/Meshtastic.Test/Data/FromDeviceMessageTests.cs b/Meshtastic.Test/Data/FromDeviceMessageTests.cs index 62731c7..d1cf301 100644 --- a/Meshtastic.Test/Data/FromDeviceMessageTests.cs +++ b/Meshtastic.Test/Data/FromDeviceMessageTests.cs @@ -21,7 +21,7 @@ public void FromDeviceMessage_SwallowsException_Given_BadPayload() { fromDeviceMessage.ParsedFromRadio(BitConverter.GetBytes(123456)); }; - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Test] @@ -29,7 +29,7 @@ public void FromDeviceMessage_ReturnsNull_Given_NoVariantPayload() { var fromRadio = new FromRadio() { }; var message = fromDeviceMessage.ParsedFromRadio(fromRadio.ToByteArray()); - message.Should().BeNull(); + message.ShouldBeNull(); } [Test] @@ -47,6 +47,6 @@ public void FromDeviceMessage_GivesResult_Given_ValidFromRadioPayload() } }; var result = fromDeviceMessage.ParsedFromRadio(fromRadio.ToByteArray()); - result!.GetPayload()!.BeginEditSettings.Should().BeTrue(); + result!.GetPayload()!.BeginEditSettings.ShouldBeTrue(); } } diff --git a/Meshtastic.Test/Data/PositionMessageFactoryTests.cs b/Meshtastic.Test/Data/PositionMessageFactoryTests.cs index 3cb5f8d..f40e51c 100644 --- a/Meshtastic.Test/Data/PositionMessageFactoryTests.cs +++ b/Meshtastic.Test/Data/PositionMessageFactoryTests.cs @@ -29,6 +29,6 @@ public void Setup() public void CreatePositionPacket_Should_ReturnValidAdminMessage() { var result = factory.CreatePositionPacket(new Position()); - result.Decoded.Portnum.Should().Be(PortNum.PositionApp); + result.Decoded.Portnum.ShouldBe(PortNum.PositionApp); } } diff --git a/Meshtastic.Test/Data/TextMessageFactoryTests.cs b/Meshtastic.Test/Data/TextMessageFactoryTests.cs index fb9ad1d..5b1bf80 100644 --- a/Meshtastic.Test/Data/TextMessageFactoryTests.cs +++ b/Meshtastic.Test/Data/TextMessageFactoryTests.cs @@ -29,6 +29,6 @@ public void Setup() public void CreateTextMessagePacket_Should_ReturnValidAdminMessage() { var result = factory.CreateTextMessagePacket("Text"); - result.Decoded.Portnum.Should().Be(PortNum.TextMessageApp); + result.Decoded.Portnum.ShouldBe(PortNum.TextMessageApp); } } diff --git a/Meshtastic.Test/Data/ToRadioFactoryTests.cs b/Meshtastic.Test/Data/ToRadioFactoryTests.cs index fa0da3c..19a01e1 100644 --- a/Meshtastic.Test/Data/ToRadioFactoryTests.cs +++ b/Meshtastic.Test/Data/ToRadioFactoryTests.cs @@ -20,20 +20,20 @@ public void CreateMeshPacketMessage_Should_ReturnValidMeshPacket() var result = factory.CreateMeshPacketMessage(new MeshPacket() { }); - result.Packet.Should().NotBeNull(); + result.Packet.ShouldNotBeNull(); } [Test] public void CreateWantConfigMessage_Should_ReturnValidWantConfig() { var result = factory.CreateWantConfigMessage(); - result.WantConfigId.Should().BeGreaterThan(0); + result.WantConfigId.ShouldBeGreaterThan((uint)0); } [Test] public void CreateXmodemPacketMessage_Should_ReturnValidXModemMessage() { var result = factory.CreateXmodemPacketMessage(); - result.XmodemPacket.Should().NotBeNull(); + result.XmodemPacket.ShouldNotBeNull(); } } diff --git a/Meshtastic.Test/Data/TraceRouteMessageFactoryTests.cs b/Meshtastic.Test/Data/TraceRouteMessageFactoryTests.cs index 657c291..cc5a0aa 100644 --- a/Meshtastic.Test/Data/TraceRouteMessageFactoryTests.cs +++ b/Meshtastic.Test/Data/TraceRouteMessageFactoryTests.cs @@ -30,7 +30,7 @@ public void CreateRouteDiscoveryPacket_Should_ReturnValidAdminMessage() { factory = new TraceRouteMessageFactory(deviceStateContainer, 100); var result = factory.CreateRouteDiscoveryPacket(); - result.Decoded.Portnum.Should().Be(PortNum.TracerouteApp); + result.Decoded.Portnum.ShouldBe(PortNum.TracerouteApp); } [Test] @@ -38,6 +38,6 @@ public void CreateRouteDiscoveryPacket_Should_ThrowNotNullException() { factory = new TraceRouteMessageFactory(deviceStateContainer); var action = () => factory.CreateRouteDiscoveryPacket(); - action.Should().Throw(); + action.ShouldThrow(); } } diff --git a/Meshtastic.Test/Data/WaypointMessageFactoryTests.cs b/Meshtastic.Test/Data/WaypointMessageFactoryTests.cs index 8a2dd43..dbe0190 100644 --- a/Meshtastic.Test/Data/WaypointMessageFactoryTests.cs +++ b/Meshtastic.Test/Data/WaypointMessageFactoryTests.cs @@ -29,6 +29,6 @@ public void Setup() public void CreateWaypointPacket_Should_ReturnValidAdminMessage() { var result = factory.CreateWaypointPacket(new Waypoint()); - result.Decoded.Portnum.Should().Be(PortNum.WaypointApp); + result.Decoded.Portnum.ShouldBe(PortNum.WaypointApp); } } diff --git a/Meshtastic.Test/Extensions/DateTimeExtensionsTests.cs b/Meshtastic.Test/Extensions/DateTimeExtensionsTests.cs index 8ccdca8..9fd2b4d 100644 --- a/Meshtastic.Test/Extensions/DateTimeExtensionsTests.cs +++ b/Meshtastic.Test/Extensions/DateTimeExtensionsTests.cs @@ -9,6 +9,6 @@ public class DateTimeExtensionsTests public void GetUnixTimestamp_Should_ReturnEpoch() { var zeroEpoch = new DateTime(1970, 1, 1); - zeroEpoch.GetUnixTimestamp().Should().Be(0); + zeroEpoch.GetUnixTimestamp().ShouldBe((uint)0); } } diff --git a/Meshtastic.Test/Extensions/DisplayExtensionsTests.cs b/Meshtastic.Test/Extensions/DisplayExtensionsTests.cs index 02f3dcd..4b2f97d 100644 --- a/Meshtastic.Test/Extensions/DisplayExtensionsTests.cs +++ b/Meshtastic.Test/Extensions/DisplayExtensionsTests.cs @@ -15,7 +15,7 @@ public void ToDisplayString_Should_ReturnNotAvailable_GivenNullPosition() #pragma warning disable CS8604 // Possible null reference argument. var result = position.ToDisplayString(); #pragma warning restore CS8604 // Possible null reference argument. - result.Should().Be("Not available"); + result.ShouldBe("Not available"); } [Test] @@ -27,7 +27,7 @@ public void ToDisplayString_Should_ReturnNotAvailable_GivenZeroLatAndLongPositio LongitudeI = 0, }; var result = position.ToDisplayString(); - result.Should().Be("Not available"); + result.ShouldBe("Not available"); } [Test] @@ -39,7 +39,7 @@ public void ToDisplayString_Should_ReturnFormattedCoordinates_GivenValidLatAndLo LongitudeI = -921234567, }; var result = position.ToDisplayString(); - result.Should().Be("34.1234567, -92.1234567"); + result.ShouldBe("34.1234567, -92.1234567"); } } } diff --git a/Meshtastic.Test/Extensions/FromRadioExtensionsTests.cs b/Meshtastic.Test/Extensions/FromRadioExtensionsTests.cs index 398bcf6..420cf94 100644 --- a/Meshtastic.Test/Extensions/FromRadioExtensionsTests.cs +++ b/Meshtastic.Test/Extensions/FromRadioExtensionsTests.cs @@ -12,16 +12,16 @@ public void GetMessage_Should_ReturnNullForBadPackets() { FromRadio fromRadio = new(); var result = fromRadio.GetPayload(); - result.Should().BeNull(); + result.ShouldBeNull(); fromRadio.Packet = new MeshPacket(); result = fromRadio.GetPayload(); - result.Should().BeNull(); + result.ShouldBeNull(); fromRadio.Packet = new MeshPacket { Decoded = new Protobufs.Data() }; result = fromRadio.GetPayload(); - result.Should().BeNull(); + result.ShouldBeNull(); } [Test] @@ -38,8 +38,8 @@ public void GetMessage_Should_ReturnValidAdminMessage() } }; result = fromRadio.GetPayload(); - result.Should().NotBeNull(); - result.Should().BeOfType(); + result.ShouldNotBeNull(); + result.ShouldBeOfType(); } [Test] @@ -56,8 +56,8 @@ public void GetMessage_Should_ReturnValidRouteDiscovery() } }; result = fromRadio.GetPayload(); - result.Should().NotBeNull(); - result.Should().BeOfType(); + result.ShouldNotBeNull(); + result.ShouldBeOfType(); } [Test] @@ -74,8 +74,8 @@ public void GetMessage_Should_ReturnValidRouting() } }; result = fromRadio.GetPayload(); - result.Should().NotBeNull(); - result.Should().BeOfType(); + result.ShouldNotBeNull(); + result.ShouldBeOfType(); } @@ -90,9 +90,9 @@ public void GetMessage_Should_ReturnValidXModemPacket() } }; var result = fromRadio.GetPayload(); - result.Should().NotBeNull(); - result.Should().BeOfType(); - result!.Control.Should().Be(XModem.Types.Control.Stx); + result.ShouldNotBeNull(); + result.ShouldBeOfType(); + result!.Control.ShouldBe(XModem.Types.Control.Stx); } } } diff --git a/Meshtastic.Test/Extensions/ReflectionExtensionsTests.cs b/Meshtastic.Test/Extensions/ReflectionExtensionsTests.cs index 15a8c37..2d4b329 100644 --- a/Meshtastic.Test/Extensions/ReflectionExtensionsTests.cs +++ b/Meshtastic.Test/Extensions/ReflectionExtensionsTests.cs @@ -13,28 +13,28 @@ public void GetSettingsOptions_Should_ThrowException_GivenNullArg() #pragma warning disable CS8631 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type. var action = () => default(LocalConfig).GetSettingsOptions(); #pragma warning restore CS8631 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type. - action.Should().Throw(); + action.ShouldThrow(); } [Test] public void GetSettingsOptions_Should_EnumerateConfigSettings() { var list = new LocalConfig().GetSettingsOptions(); - list.Should().Contain("Device.Role"); + list.ShouldContain("Device.Role"); } [Test] public void GetSettingsOptions_Should_EnumerateModuleConfigSettings() { var list = new LocalModuleConfig().GetSettingsOptions(); - list.Should().Contain("Mqtt.Address"); + list.ShouldContain("Mqtt.Address"); } [Test] public void GetProperties_Should_ReturnPropertyOnConfigSection() { var list = new LoRaConfig().GetProperties(); - list.Should().Contain(p => p.Name == "TxPower"); + list.ShouldContain(p => p.Name == "TxPower"); } [Test] @@ -42,7 +42,7 @@ public void GetSettingValue_Should_ReturnPropertyValueOnConfigSection() { var lora = new LoRaConfig() { TxPower = 100 }; var property = lora.GetProperties().First(p => p.Name == "TxPower"); - property.GetSettingValue(lora).Should().BeEquivalentTo(lora.TxPower.ToString()); + property.GetSettingValue(lora).ShouldBeEquivalentTo(lora.TxPower.ToString()); } } } diff --git a/Meshtastic.Test/Meshtastic.Test.csproj b/Meshtastic.Test/Meshtastic.Test.csproj index 937f72e..3dcc249 100644 --- a/Meshtastic.Test/Meshtastic.Test.csproj +++ b/Meshtastic.Test/Meshtastic.Test.csproj @@ -14,7 +14,6 @@ - @@ -28,6 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Meshtastic.Test/Parsers/SettingParserTests.cs b/Meshtastic.Test/Parsers/SettingParserTests.cs index c0b0398..94edf0d 100644 --- a/Meshtastic.Test/Parsers/SettingParserTests.cs +++ b/Meshtastic.Test/Parsers/SettingParserTests.cs @@ -16,11 +16,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenValidModuleCo var parser = new SettingParser(new[] { "mqtt.enabled" }); var result = parser.ParseSettings(isGetOnly: true); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("Enabled")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Mqtt")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().BeNull()); + result.ParsedSettings.All(p => p.Setting.Name == "Enabled").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Mqtt").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is null).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } [Test] @@ -29,11 +29,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenValidModuleCo var parser = new SettingParser(new[] { "mqtt.enabled=true" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("Enabled")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Mqtt")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().Be(true)); + result.ParsedSettings.All(p => p.Setting.Name == "Enabled").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Mqtt").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is true).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } //[Test] @@ -42,11 +42,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenValidModuleCo // var parser = new SettingParser(new[] { "mqtt.enabled=1" }); // var result = parser.ParseSettings(isGetOnly: false); - // result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("Enabled")); - // result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Mqtt")); - // result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().Be(true)); + // result.ParsedSettings.All(p => p.Setting.Name == "Enabled").ShouldBeTrue(); + // result.ParsedSettings.All(p => p.Section.Name == "Mqtt").ShouldBeTrue(); + // result.ParsedSettings.All(p => p.Value is true).ShouldBeTrue(); - // result.ValidationIssues.Should().BeEmpty(); + // result.ValidationIssues.ShouldBeEmpty(); //} [Test] @@ -55,11 +55,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenEnumValue_Set var parser = new SettingParser(new[] { "serial.baud=Baud19200" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("Baud")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Serial")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().Be(Serial_Baud.Baud19200)); + result.ParsedSettings.All(p => p.Setting.Name == "Baud").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Serial").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is Serial_Baud.Baud19200).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } [Test] @@ -68,11 +68,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenValidConfigAr var parser = new SettingParser(new[] { "display.screenOnSecs" }); var result = parser.ParseSettings(isGetOnly: true); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("ScreenOnSecs")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Display")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().BeNull()); + result.ParsedSettings.All(p => p.Setting.Name == "ScreenOnSecs").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Display").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is null).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } [Test] @@ -81,8 +81,8 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenBardArgs_Set( var parser = new SettingParser(new[] { "screenOnSecs" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } [Test] @@ -91,8 +91,8 @@ public void ParseSettings_Should_ReturnValidationIssues_GivenBadArgs_Set() var parser = new SettingParser(new[] { "screenOnSecs=42" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } [Test] @@ -101,8 +101,8 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenMissingSectio var parser = new SettingParser(new[] { "doesntexist.enabled" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } [Test] @@ -111,8 +111,8 @@ public void ParseSettings_Should_ReturnValidationIssues_GivenMissingSection_Set( var parser = new SettingParser(new[] { "doesntexist.enabled=true" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } @@ -122,8 +122,8 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenMissingSettin var parser = new SettingParser(new[] { "mqtt.derp" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } [Test] @@ -132,8 +132,8 @@ public void ParseSettings_Should_ReturnValidationIssues_GivenMissingSetting_Set( var parser = new SettingParser(new[] { "mqtt.derp=true" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().BeEmpty(); - result.ValidationIssues.Should().HaveCount(1); + result.ParsedSettings.ShouldBeEmpty(); + result.ValidationIssues.Count().ShouldBe(1); } [Test] @@ -142,11 +142,11 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenSnakeCase() var parser = new SettingParser(new[] { "display.screen_on_secs" }); var result = parser.ParseSettings(isGetOnly: true); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("ScreenOnSecs")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Display")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().BeNull()); + result.ParsedSettings.All(p => p.Setting.Name == "ScreenOnSecs").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Display").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is null).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } [Test] @@ -155,10 +155,10 @@ public void ParseSettings_Should_SetFloatValue() var parser = new SettingParser(new[] { "Power.AdcMultiplierOverride=2.5" }); var result = parser.ParseSettings(isGetOnly: false); - result.ParsedSettings.Should().AllSatisfy(p => p.Setting.Name.Should().BeEquivalentTo("AdcMultiplierOverride")); - result.ParsedSettings.Should().AllSatisfy(p => p.Section.Name.Should().BeEquivalentTo("Power")); - result.ParsedSettings.Should().AllSatisfy(p => p.Value.Should().BeEquivalentTo(2.5)); + result.ParsedSettings.All(p => p.Setting.Name == "AdcMultiplierOverride").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Section.Name == "Power").ShouldBeTrue(); + result.ParsedSettings.All(p => p.Value is float f && f == 2.5f).ShouldBeTrue(); - result.ValidationIssues.Should().BeEmpty(); + result.ValidationIssues.ShouldBeEmpty(); } } diff --git a/Meshtastic.Test/Parsers/UrlParserTests.cs b/Meshtastic.Test/Parsers/UrlParserTests.cs index 14bdd80..f5a208a 100644 --- a/Meshtastic.Test/Parsers/UrlParserTests.cs +++ b/Meshtastic.Test/Parsers/UrlParserTests.cs @@ -18,7 +18,7 @@ public void Parse_Should_ReturnChannelSet_GivenValidMeshtasticUrl() var url = "https://meshtastic.org/e/#CjMSIK4kboySjOqKWHn8dCR2Gp7L0syIGv1_sySCrbZxneV2GgtCZW5zRnVuTGFuZCgBMAEKKRIgarYveKnCBHSGrOMkzVVStMEElngYZQir38xCiDKkj6UaBWFkbWluCisSIExfvRlaRwJWHDEvQYaUjzwUeN4FvkI_6nJX9P0ByHCOGgdQYXJ0eU9uEgoIATgBQANIAVAe"; var parser = new UrlParser(url); var result = parser.ParseChannels(); - result.Settings[0].Name.Should().Be("BensFunLand"); + result.Settings[0].Name.ShouldBe("BensFunLand"); } [Test] @@ -49,7 +49,7 @@ public void Parse_Should_ReturnContact_GivenValidMeshtasticUrl() var url = $"https://meshtastic.org/v/#{base64}"; var parser = new UrlParser(url); var result = parser.ParseContact(); - result.User.LongName.Should().Be("Benben"); + result.User.LongName.ShouldBe("Benben"); } [Test] @@ -58,13 +58,13 @@ public void Should_ThrowException_GivenNoMeshtasticUrl() #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. var action = () => new UrlParser(null); #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. - action.Should().Throw(); + action.ShouldThrow(); } [Test] public void Should_ThrowException_GivenEmptyMeshtasticUrl() { var action = () => new UrlParser(String.Empty); - action.Should().Throw(); + action.ShouldThrow(); } } diff --git a/Meshtastic.Test/Reflection/ReflectionExtensionsTests.cs b/Meshtastic.Test/Reflection/ReflectionExtensionsTests.cs index df701fb..53c07cd 100644 --- a/Meshtastic.Test/Reflection/ReflectionExtensionsTests.cs +++ b/Meshtastic.Test/Reflection/ReflectionExtensionsTests.cs @@ -15,6 +15,6 @@ public void ParseSettings_Should_ReturnResultWithPropertyInfo_GivenValidModuleCo { var configs = new LocalConfig().GetSettingsOptions(); - configs.Should().Contain("Display.ScreenOnSecs"); + configs.ShouldContain("Display.ScreenOnSecs"); } } diff --git a/Meshtastic.Test/Usings.cs b/Meshtastic.Test/Usings.cs index 0ba4136..8a2e44e 100644 --- a/Meshtastic.Test/Usings.cs +++ b/Meshtastic.Test/Usings.cs @@ -1,4 +1,4 @@ global using Moq; -global using FluentAssertions; +global using Shouldly; global using Meshtastic.Data; global using NUnit.Framework; diff --git a/Meshtastic.Test/Utilities/FirmwarePackageServiceTests.cs b/Meshtastic.Test/Utilities/FirmwarePackageServiceTests.cs index 58437c1..aff9848 100644 --- a/Meshtastic.Test/Utilities/FirmwarePackageServiceTests.cs +++ b/Meshtastic.Test/Utilities/FirmwarePackageServiceTests.cs @@ -10,8 +10,7 @@ public async Task GetLast5Releases_Should_Return5Records() { var github = new FirmwarePackageService(); var releases = await github.GetFirmwareReleases(); - releases.releases.stable.Should().HaveCountGreaterThan(0); - releases.releases.stable.Should().HaveCountGreaterThan(0); + releases.releases.stable.Count().ShouldBeGreaterThan(0); } [Test] @@ -20,7 +19,7 @@ public async Task DownloadRelease_Should_ReturnMemoryStream() var github = new FirmwarePackageService(); var releases = await github.GetFirmwareReleases(); var memoryStream = await github.DownloadRelease(releases.releases.alpha.First()); - memoryStream.Length.Should().BeGreaterThan(0); + memoryStream.Length.ShouldBeGreaterThan(0); } } } diff --git a/Meshtastic.Test/Utilities/ReleaseZipServiceTests.cs b/Meshtastic.Test/Utilities/ReleaseZipServiceTests.cs index dcd4be1..f6aff39 100644 --- a/Meshtastic.Test/Utilities/ReleaseZipServiceTests.cs +++ b/Meshtastic.Test/Utilities/ReleaseZipServiceTests.cs @@ -26,7 +26,7 @@ public async Task ExtractBinaries_Should_DownloadUpdateBin_ForLatestEsp32Release var releases = await github.GetFirmwareReleases(); var memoryStream = await github.DownloadRelease(releases.releases.stable.First()); var path = await service.ExtractUpdateBinary(memoryStream, HardwareModel.Tbeam); - path.Should().EndWith("update.bin"); + path.ShouldEndWith("update.bin"); File.Delete(path); } }