예제 #1
0
        public void TestCompressedBytesToStringInvalidLength2()
        {
            byte[] testBytes =
            {
                2, (byte)'a', 0,
            };

            Assert.Throws <IndexOutOfRangeException>(
                () => DomainName.CompressedBytesToString(testBytes)
                );
        }
예제 #2
0
        public void TestCompressedBytesToStringInvalidLength3()
        {
            byte[] testBytes =
            {
                0, (byte)'a', 0,
            };

            Assert.Throws <Exception>(
                () => DomainName.CompressedBytesToString(testBytes)
                );
        }
예제 #3
0
        public void TestCompressedBytesToString()
        {
            byte[] testBytes =
            {
                7,         (byte)'e', (byte)'x', (byte)'a', (byte)'m', (byte)'p', (byte)'l', (byte)'e',         3, (byte)'c',
                (byte)'o', (byte)'m',         0,         7, (byte)'e', (byte)'x', (byte)'a', (byte)'m', (byte)'p', (byte)'l',
                (byte)'e',         3, (byte)'n', (byte)'e', (byte)'t',         0,
            };

            List <string> expected = new List <string> {
                "example.com", "example.net"
            };

            List <string> actual = DomainName.CompressedBytesToString(testBytes);

            Assert.Equal(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.True(expected[i] == actual[i],
                            String.Format("Expected '{0}' Actual: '{1}'", expected[i], actual[i])
                            );
            }
        }