Пример #1
0
        public void ParseNetascii_NoNullTerminator_ThrowsArgumentException()
        {
            byte[] b   = new byte[] { 65, 66 };
            int    pos = 0;

            TftpPacketUtils.ParseNetascii(b, ref pos);
        }
Пример #2
0
        public void ParseNetascii_OnlyNullTerminator_ReturnsEmptyString()
        {
            byte[] b   = new byte[] { 0 };
            int    pos = 0;
            string s   = TftpPacketUtils.ParseNetascii(b, ref pos);

            Debug.Assert(pos == 1);
            Debug.Assert(s == "");
        }
Пример #3
0
        public void ParseNetascii_SingleString()
        {
            byte[] b   = new byte[] { 65, 66, 0 };
            int    pos = 0;
            string s   = TftpPacketUtils.ParseNetascii(b, ref pos);

            Debug.Assert(pos == 3);
            Debug.Assert(s == "AB");
        }
Пример #4
0
        public void ParseNetascii_MultipleStrings()
        {
            byte[] b   = new byte[] { 65, 66, 0, 67, 68, 0, 69, 70, 0 };
            int    pos = 0;
            string s1  = TftpPacketUtils.ParseNetascii(b, ref pos);

            Debug.Assert(pos == 3);
            Debug.Assert(s1 == "AB");
            string s2 = TftpPacketUtils.ParseNetascii(b, ref pos);

            Debug.Assert(pos == 6);
            Debug.Assert(s2 == "CD");
            string s3 = TftpPacketUtils.ParseNetascii(b, ref pos);

            Debug.Assert(pos == 9);
            Debug.Assert(s3 == "EF");
        }