Пример #1
0
        public void Null()
        {
            PacketBuilder pb = new PacketBuilder();

            pb.Write(null);

            byte[] data = pb.ToArray();

            Assert.AreEqual(1, data.Length);
            Assert.AreEqual(0, data[0]);
        }
Пример #2
0
        public UdpBuildReporter(string host, int destinationPort)
        {
            sendSocket = new Socket(AddressFamily.InterNetwork,
                SocketType.Dgram, ProtocolType.Udp);

            IPAddress dstAddr = GetIPv4Address(host);

            endPoint = new IPEndPoint(dstAddr, destinationPort);

            packetBuilder = new PacketBuilder();
        }
Пример #3
0
        public void Reset()
        {
            PacketBuilder pb = new PacketBuilder();

            pb.Write("hello");

            Assert.AreEqual(6, pb.ToArray().Length);

            pb.Reset();

            Assert.AreEqual(0, pb.ToArray().Length);
        }
Пример #4
0
        public void Longer()
        {
            PacketBuilder pb = new PacketBuilder();

            pb.Write("hello123hello123hello123hello123hello123hello123hello123hello123" +
                "hello123hello123hello123hello123hello123hello123hello123hello123" +
                "hello123hello123hello123hello123hello123hello123hello123hello123" +
                "hello123hello123hello123hello123hello123hello123hello123hello123" +
                "hello123hello123hello123hello123hello123hello123hello123hello12");

            byte[] data = pb.ToArray();

            Assert.AreEqual(320, data.Length);
            Assert.AreEqual(0, data[319]);
        }
Пример #5
0
        public void Simple()
        {
            PacketBuilder pb = new PacketBuilder();

            pb.Write("hello");

            byte[] data = pb.ToArray();

            Assert.AreEqual(6, data.Length);
            Assert.AreEqual((byte) 'h', data[0]);
            Assert.AreEqual((byte) 'e', data[1]);
            Assert.AreEqual((byte) 'l', data[2]);
            Assert.AreEqual((byte) 'l', data[3]);
            Assert.AreEqual((byte) 'o', data[4]);
            Assert.AreEqual((byte) 0, data[5]);
        }