public void ReceivedShouldBeEqualToLatest()
        {
            ushort nextReceive = maxSequence;

            for (int i = 0; i < messageCount; i++)
            {
                int    offset   = 3;
                ushort received = ByteUtils.ReadUShort(instance1.packet(i), ref offset);
                Assert.That(received, Is.EqualTo(nextReceive), "Received should start at max and increment each time");

                // do at end becuase 1 is sending first
                if (received1[i])
                {
                    nextReceive = (ushort)(i);
                }
            }

            nextReceive = maxSequence;
            for (int i = 0; i < messageCount; i++)
            {
                // do at start becuase 2 is sending second
                if (received2[i])
                {
                    nextReceive = (ushort)(i);
                }

                int    offset   = 3;
                ushort received = ByteUtils.ReadUShort(instance2.packet(i), ref offset);
                Assert.That(received, Is.EqualTo(nextReceive), "Received should start at 1 (received first message before sending) and increment each time");
            }
        }
Exemplo n.º 2
0
 public void PacketsShouldBeNotify()
 {
     for (int i = 0; i < messageCount; i++)
     {
         int  offset     = 0;
         byte packetType = ByteUtils.ReadByte(instance.packet(i), ref offset);
         Assert.That((PacketType)packetType, Is.EqualTo(PacketType.Notify));
     }
 }
 public void EachPacketHasDifferentAckSequence()
 {
     for (int i = 0; i < instance.connection.packets.Count; i++)
     {
         int    offset   = 1;
         ushort sequance = ByteUtils.ReadUShort(instance.packet(i), ref offset);
         Assert.That(sequance, Is.EqualTo(i));
     }
 }
Exemplo n.º 4
0
        public void AllPacketsShouldBeNotify()
        {
            for (var i = 0; i < messageCount; i++)
            {
                var offset     = 0;
                var packetType = ByteUtils.ReadByte(instance1.packet(i), ref offset);
                Assert.That((PacketType)packetType, Is.EqualTo(PacketType.Notify));
            }

            for (var i = 0; i < messageCount; i++)
            {
                var offset     = 0;
                var packetType = ByteUtils.ReadByte(instance2.packet(i), ref offset);
                Assert.That((PacketType)packetType, Is.EqualTo(PacketType.Notify));
            }
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            config = new Config();
            var mtu     = MAX_PACKET_SIZE;
            var bigSize = (int)(mtu * 1.5f);

            message = CreateBigData(1, bigSize);

            var sender = new AckTestInstance();

            sender.connection = new SubIRawConnection();
            sender.ackSystem  = new AckSystem(sender.connection, config, MAX_PACKET_SIZE, new Time(), bufferPool);
            sender.ackSystem.SendReliable(message);
            packet1 = sender.packet(0);
            packet2 = sender.packet(1);


            var connection = new SubIRawConnection();

            ackSystem = new AckSystem(connection, config, MAX_PACKET_SIZE, new Time(), bufferPool);
        }