using FluentAssertions; using MultiTerm.Protocols.Model; namespace MultiTerm.Protocols.Tests; [TestFixture(Author = "JonasArnold")] public class ExtendedByteTests { // testname: thema_aktion_expectedout // ablauf: arrange, act, assert [SetUp] public void Setup() { } [Test] [TestCase((byte)40 , "(")] [TestCase((byte)10, "\n")] [TestCase((byte)13, "\r")] [TestCase((byte)32, " ")] [TestCase((byte)125, "}")] [TestCase((byte)128, "?")] public void ToString_ByteConverted_ResultsInAsciiEncodedString(byte dataByte, string expectedOutcome) { // Arrange ExtendedByte extdByte = new(dataByte); // Act var toStringResult = extdByte.ToString(); // Assert toStringResult.Should().BeEquivalentTo(expectedOutcome); } [Test] [TestCase((byte)40, "(")] [TestCase((byte)10, "\u240A")] [TestCase((byte)13, "\u240D")] [TestCase((byte)32, " ")] [TestCase((byte)125, "}")] [TestCase((byte)128, "?")] public void ToCharacterString_ByteConverted_ResultsInDisplayableCharacterString(byte dataByte, string expectedOutcome) { // Arrange ExtendedByte extdByte = new(dataByte); // Act var toStringResult = extdByte.ToCharacterString(); // Assert toStringResult.Should().BeEquivalentTo(expectedOutcome); } [Test] [TestCase((byte)30, "00011110")] [TestCase((byte)10, "00001010")] [TestCase((byte)240, "11110000")] public void ToBinaryString_ByteConverted_ResultsInCorrectlyFormattedBinaryString(byte dataByte, string expectedOutcome) { // Arrange ExtendedByte extdByte = new(dataByte); // Act var toStringResult = extdByte.ToBinaryString(); // Assert toStringResult.Should().BeEquivalentTo(expectedOutcome); } [Test] [TestCase((byte)2, "02")] [TestCase((byte)10, "0A")] [TestCase((byte)127, "7F")] [TestCase((byte)240, "F0")] public void ToHexString_ByteConverted_ResultsInCorrectlyFormattedHexString(byte dataByte, string expectedOutcome) { // Arrange ExtendedByte extdByte = new(dataByte); // Act var toStringResult = extdByte.ToHexString(); // Assert toStringResult.Should().BeEquivalentTo(expectedOutcome); } }