Пример #1
0
 public void BitwiseNot_NullInput_ThrowsArgumentNullException_Test()
 {
     // Arrange
     // Act
     // Assert
     // ReSharper disable once AssignNullToNotNullAttribute
     Assert.Throws <ArgumentNullException>(() => ByteArrayUtils.BitwiseNot(null));
 }
Пример #2
0
        public void BitwiseNot_Test(byte[] expected,
                                    byte[] input)
        {
            // Arrange
            var original = input.ToArray();

            // Act
            var result = ByteArrayUtils.BitwiseNot(input);

            // Assert
            Assert.Equal(expected, result);

            Assert.Equal(original, input); // input value not affected
        }
Пример #3
0
        public static void BitwiseNotExample()
        {
            // Setup
            var input = new byte[] { 0x00, 0x11, 0xAC, 0xFF };

            // Act
            var result = ByteArrayUtils.BitwiseNot(input);

            // Conclusion
            Console.WriteLine("BitwiseNot Example");
            Console.WriteLine($"input:\t{input.ToString("H")}");
            Console.WriteLine($"result:\t{result.ToString("H")}");
            Console.WriteLine(string.Empty);
            Console.WriteLine($"input:\t{input.ToString("b")}");
            Console.WriteLine($"result:\t{result.ToString("b")}");
            Console.WriteLine(string.Empty);
        }
Пример #4
0
        public static IEnumerable <object[]> LogicalNot_Test_Values()
        {
            foreach (var bytes in Values())
            {
                var expected = new FixedBytes(ByteArrayUtils.BitwiseNot(bytes));
                yield return(new object[] { expected, new FixedBytes(bytes) });
            }

            yield return(new object[] { null, null });

            IEnumerable <byte[]> Values()
            {
                yield return(Array.Empty <byte>());

                yield return(new byte[] { 0x00 });

                yield return(new byte[] { 0x0F });

                yield return(new byte[] { 0xAC, 0xCA });
            }
        }