コード例 #1
0
        public void TrafficViewerEncoder_GetString()
        {
            TrafficViewerEncoding enc = new TrafficViewerEncoding();
            string result             = enc.GetString(new byte[3] {
                49, 0, 50
            });

            Assert.AreEqual(@"1\x00002", result);
        }
コード例 #2
0
        public void TrafficViewerEncoder_GetBytesWrongSlash()
        {
            TrafficViewerEncoding enc = new TrafficViewerEncoding();

            byte[] expected = new byte[3] {
                49, 92, 50
            };
            byte[] result = enc.GetBytes(@"1\2");
            Assert.AreEqual(expected.Length, result.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }

            string resultS = enc.GetString(result);

            Assert.AreEqual(@"1\2", resultS);
        }
コード例 #3
0
        public void TrafficViewerEncoder_GetBytes()
        {
            TrafficViewerEncoding enc = new TrafficViewerEncoding();

            byte [] expected = new byte[3] {
                49, 0, 50
            };
            byte [] result = enc.GetBytes(@"1\x00002");
            Assert.AreEqual(expected.Length, result.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }

            string expectedS = "HTTP 200 OK\r\n<r>1</r>";

            result = enc.GetBytes(expectedS);
            Assert.AreEqual(enc.GetString(result), expectedS);
        }