Beispiel #1
0
        public ClientPacketSafe ProcessOnly(BaseClientPacketMock expected)
        {
            ClientPacketSafe result = ClientPacket.Instantiate((byte *)Socket, Socket->Data[0], expected.Length, expected.Dynamic);

            CoreEvents.OnPacketReceived((byte *)Socket, expected.PacketID, expected.Length, expected.Dynamic);
            return(result);
        }
Beispiel #2
0
        public ClientPacketSafe ProcessAndCheck(BaseClientPacketMock expected)
        {
            ClientPacketSafe result = ProcessOnly(expected);

            expected.VerifyTransform(result);

            return(result);
        }
Beispiel #3
0
        public override void VerifyTransform(ClientPacketSafe resultPacket)
        {
            Packet80_LoginRequest packet = resultPacket as Packet80_LoginRequest;

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

            int  accountid;
            bool userAsExpected = packet.Username == "denied" || int.TryParse(packet.Username, out accountid);
            bool passCleared    = string.IsNullOrEmpty(packet.Password);

            if (!userAsExpected || !passCleared)
            {
                throw new VerificationException("Data unexpected in Packet80_LoginRequest. user: {0}  pass: {1}", packet.Username, packet.Password);
            }
        }
        unsafe public void Packet00_CreateCharConstructorTest_Normal()
        {
            using (MockClient client = new MockClient(42, TestUserIP))
            {
                client.Version = ClientVersion.v1_26_2.Version;

                Assert.AreEqual(0u, client.SocketDataLength, "Data length should be zero");

                MockClient_00_CreateCharater packetIn = new MockClient_00_CreateCharater(client.Version);

                packetIn.StartX    = 43;
                packetIn.StartY    = 75;
                packetIn.StartZ    = 0;
                packetIn.Female    = 1;
                packetIn.Str       = 49;
                packetIn.Int       = 50;
                packetIn.Dex       = 25;
                packetIn.Skill1    = 22;
                packetIn.Skill1val = 30;
                packetIn.Skill2    = 6;
                packetIn.Skill2val = 3;
                packetIn.Skill3    = 21;
                packetIn.Skill3val = 53;

                client.Enqueue(packetIn);

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

                try
                {
                    ClientPacketSafe packetOut = client.ProcessAndCheck(packetIn);
                }
                catch (VerificationException ex)
                {
                    Assert.Fail(ex.Message);
                }

                Assert.AreEqual(MockClient_00_CreateCharater.expectedLen, client.SocketDataLength, "Socket should still contain packet, length should be {0}.", MockClient_00_CreateCharater.expectedLen);
            }
        }
Beispiel #5
0
 public abstract void VerifyTransform(ClientPacketSafe resultPacket);