Ejemplo n.º 1
0
    public void GamestatePacketSerializeTestB()
    {
        GamestatePacket gamestatePacket = new GamestatePacket();

        gamestatePacket.revisionNumber = 5899;
        gamestatePacket.revisionActor  = 0xF7;
        gamestatePacket.id             = 12;
        gamestatePacket.hasName        = false;
        gamestatePacket.name           = "AAAAABBB";

        gamestatePacket.hasShortValues[0] = false;
        gamestatePacket.hasShortValues[1] = true;
        gamestatePacket.shortValues.Add(6);
        gamestatePacket.hasShortValues[2] = true;
        gamestatePacket.shortValues.Add(1359);
        gamestatePacket.hasShortValues[3] = true;
        gamestatePacket.shortValues.Add(13590);
        gamestatePacket.hasShortValues[4] = false;
        gamestatePacket.hasShortValues[5] = true;
        gamestatePacket.shortValues.Add(-13590);
        gamestatePacket.hasShortValues[6] = false;
        gamestatePacket.hasShortValues[7] = true;
        gamestatePacket.shortValues.Add(67);
        gamestatePacket.hasShortValues[8]  = false;
        gamestatePacket.hasShortValues[9]  = false;
        gamestatePacket.hasShortValues[10] = false;
        gamestatePacket.hasShortValues[11] = false;
        gamestatePacket.hasShortValues[12] = false;
        gamestatePacket.hasShortValues[13] = false;
        gamestatePacket.hasShortValues[14] = true;
        gamestatePacket.shortValues.Add(0);
        gamestatePacket.hasShortValues[15] = false;

        gamestatePacket.boolValues[0]  = false;
        gamestatePacket.boolValues[1]  = true;
        gamestatePacket.boolValues[2]  = true;
        gamestatePacket.boolValues[3]  = true;
        gamestatePacket.boolValues[4]  = false;
        gamestatePacket.boolValues[5]  = true;
        gamestatePacket.boolValues[6]  = false;
        gamestatePacket.boolValues[7]  = true;
        gamestatePacket.boolValues[8]  = false;
        gamestatePacket.boolValues[9]  = false;
        gamestatePacket.boolValues[10] = true;
        gamestatePacket.boolValues[11] = true;
        gamestatePacket.boolValues[12] = false;
        gamestatePacket.boolValues[13] = false;
        gamestatePacket.boolValues[14] = true;

        byte[] serializedPacket = GamestatePacket.Serialize(gamestatePacket);

        Assert.That(serializedPacket, Is.Not.Null);
        Assert.That(serializedPacket, Is.Not.Empty);

        GamestatePacket newPacket = GamestatePacket.Deserialize(serializedPacket) as GamestatePacket;

        Assert.That(newPacket, Is.Not.Null);

        GamestateAssertionUnit.AssertPacketEquality(gamestatePacket, newPacket);
    }
Ejemplo n.º 2
0
    public void GamestatePacketSerializeTestC()
    {
        GamestateRandomTestingUnit generator = new GamestateRandomTestingUnit(5);

        for (int i = 0; i < 100; i++)
        {
            GamestatePacket gamestatePacket = generator.GetRandomPacket();

            byte[] serializedPacket = GamestatePacket.Serialize(gamestatePacket);

            Assert.That(serializedPacket, Is.Not.Null);
            Assert.That(serializedPacket, Is.Not.Empty);

            GamestatePacket newPacket = GamestatePacket.Deserialize(serializedPacket) as GamestatePacket;

            Assert.That(newPacket, Is.Not.Null);

            GamestateAssertionUnit.AssertPacketEquality(gamestatePacket, newPacket);
        }
    }