예제 #1
0
        unsafe public void Packet00_CreateCharConstructorTest_FixSkills()
        {
            using (MockClient client = new MockClient(42, TestUserIP))
            {
                Assert.AreEqual(0u, client.SocketDataLength, "Data length should be zero");

                MockClient_00_CreateCharater packetIn = new MockClient_00_CreateCharater(client.Version);

                byte skill1 = 22;
                byte skill2 = 22;
                byte skill3 = 100;

                byte skill1Val = 24;
                byte skill2Val = 34;
                byte skill3val = 153;

                packetIn.StartX    = 23;
                packetIn.StartY    = 15;
                packetIn.StartZ    = 10;
                packetIn.Female    = 0;
                packetIn.Str       = 49;
                packetIn.Int       = 50;
                packetIn.Dex       = 25;
                packetIn.Skill1    = skill1;
                packetIn.Skill1val = skill1Val;
                packetIn.Skill2    = skill2;
                packetIn.Skill2val = skill2Val;
                packetIn.Skill3    = skill3;
                packetIn.Skill3val = skill3val;

                client.Enqueue(packetIn);

                Assert.AreEqual(packetIn.Length, client.SocketDataLength, "Socket should contain packet, datalength should equal packet length.");

                Packet00_CreateChar packetOut = client.ProcessOnly(packetIn) as Packet00_CreateChar;

                Assert.AreEqual(MockClient_00_CreateCharater.expectedLen, (uint)packetOut.Length, "Unexpected packet size.");

                Assert.AreNotEqual(packetOut.Skill1, packetOut.Skill2, "Skill1 and Skill2 should not be equal.");
                Assert.AreNotEqual(packetOut.Skill1, packetOut.Skill3, "Skill1 and Skill3 should not be equal.");
                Assert.AreNotEqual(packetOut.Skill2, packetOut.Skill3, "Skill2 and Skill3 should not be equal.");

                Assert.IsTrue(packetOut.Skill3 >= 0 && packetOut.Skill3 < Server.SkillsObject.SkillCount, "Skill3 is out of range: {0}", packetOut.Skill3);

                Assert.AreEqual(skill1Val, packetOut.Skill1val, "Skill1 value mismatch");
                Assert.AreEqual(skill2Val, packetOut.Skill2val, "Skill2 value mismatch");
                Assert.AreEqual(skill3val, packetOut.Skill3val, "Skill3 value mismatch");

                Assert.AreEqual(packetIn.Length, client.SocketDataLength, "Socket should still contain packet.");
            }
        }
예제 #2
0
        public override void VerifyTransform(Sharpkick.Network.ClientPacketSafe resultPacket)
        {
            Packet00_CreateChar packet = resultPacket as Packet00_CreateChar;

            if (packet == null)
            {
                throw new VerificationException("Expected Packet00_CreateChar. Unexpected underlying packet type: {0}", resultPacket.GetType());
            }

            for (uint i = 0; i < expectedLen; i++)
            {
                if (packet[i] != PacketData[i])
                {
                    throw new VerificationException("Data verification failed at index {0}", i);
                }
            }
        }