public void BitwiseXorLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left,
                                                                               byte[] right)
 {
     // Arrange
     // Act
     // Assert
     Assert.Throws <ArgumentNullException>(() => ByteArrayUtils.BitwiseXorLittleEndian(left, right));
 }
        public void BitwiseXorLittleEndian_Test(byte[] expected,
                                                byte[] left,
                                                byte[] right)
        {
            // Arrange
            var leftOriginal  = left.ToArray();
            var rightOriginal = right.ToArray();

            // Act
            var result = ByteArrayUtils.BitwiseXorLittleEndian(left, right);

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

            Assert.Equal(leftOriginal, left);   // input value not affected
            Assert.Equal(rightOriginal, right); // input value not affected
        }
Пример #3
0
        public static void BitwiseXorLittleEndianExample()
        {
            // Setup
            var lhs = new byte[] { 0xC0, 0xDE };
            var rhs = new byte[] { 0xC0, 0xFF, 0xEE };

            // Act
            var result = ByteArrayUtils.BitwiseXorLittleEndian(lhs, rhs);

            // Conclusion
            Console.WriteLine("BitwiseXorLittleEndian Example");
            Console.WriteLine($"lhs:\t{lhs.ToString("H")}");
            Console.WriteLine($"rhs:\t{rhs.ToString("H")}");
            Console.WriteLine($"result:\t{result.ToString("H")}");
            Console.WriteLine(string.Empty);
            Console.WriteLine($"lhs:\t{lhs.ToString("b")}");
            Console.WriteLine($"rhs:\t{rhs.ToString("b")}");
            Console.WriteLine($"result:\t{result.ToString("b")}");
            Console.WriteLine(string.Empty);
        }