예제 #1
0
 public void ClientEnqueue(FakePacket packet, string address, int port)
 {
     recvQueue.Enqueue(new FakeData()
     {
         data = packet.GetData(), endPoint = new FakeEndPoint(address, port)
     });
 }
        public void TestCommandError()
        {
            FakePacket packet = new FakePacket('4', 1.0f, 1.0f);

            transport.ClientEnqueue(packet, "tester", 0);

            Assert.That(() => server.SingleStep(), Throws.InstanceOf <ServerException>());
        }
        public void TestDivisionWithZeroB()
        {
            FakePacket packet = new FakePacket('3', 10.0f, 0.0f);

            transport.ClientEnqueue(packet, "tester", 0);

            Assert.That(() => server.SingleStep(), Throws.InstanceOf <ServerException>());
        }
        public void TestDivision()
        {
            FakePacket packet = new FakePacket('3', 10.0f, 5.0f);

            transport.ClientEnqueue(packet, "tester", 0);
            server.SingleStep();
            float result = BitConverter.ToSingle(transport.ClientDequeue().data, 0);

            Assert.That(result, Is.EqualTo(2.0f));
        }
        public void TestSubtractionWithZero()
        {
            FakePacket packet = new FakePacket('1', 0.0f, 0.0f);

            transport.ClientEnqueue(packet, "tester", 0);
            server.SingleStep();
            float result = BitConverter.ToSingle(transport.ClientDequeue().data, 0);

            Assert.That(result, Is.EqualTo(0.0f));
        }
        public void TestAdditionNegative()
        {
            FakePacket packet = new FakePacket('0', -1.0f, -1.0f);

            transport.ClientEnqueue(packet, "tester", 0);
            server.SingleStep();
            float result = BitConverter.ToSingle(transport.ClientDequeue().data, 0);

            Assert.That(result, Is.EqualTo(-2.0f));
        }