Exemple #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);
        }
Exemple #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);
        }
        public void Encoding_SimpleControl()
        {
            string controlText = "The quick brown hair \r\n\0 jumps over the lazy fox";
            TrafficViewerEncoding testEncoding = new TrafficViewerEncoding();
            Encoding controlEncoding           = Encoding.UTF8;

            byte[] testBytes    = testEncoding.GetBytes(controlText);
            byte[] controlBytes = controlEncoding.GetBytes(controlText);

            //compare the generated bytes
            Assert.AreEqual(controlBytes.Length, testBytes.Length, "Incorrect byte lenghts");

            int len = testBytes.Length;

            for (int idx = 0; idx < len; idx++)
            {
                Assert.AreEqual(controlBytes[idx], testBytes[idx], "Incorrect bytes at position {0}", idx);
            }
        }
Exemple #4
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);
        }