public void TestUpdateGoldSecureTrade(int gold, int plat, TradeFlag flag)
        {
            var cont     = new Container(World.NewItem);
            var expected = new UpdateSecureTrade(cont, flag, gold, plat).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendUpdateSecureTrade(cont, flag, gold, plat);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
        // Update first
        // Update second
        public void TestUpdateSecureTrade(bool first, bool second)
        {
            var firstCont  = new Container(World.NewItem);
            var secondCont = new Container(World.NewItem);

            var cont     = first ? firstCont : secondCont;
            var expected = new UpdateSecureTrade(cont, first, second).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendUpdateSecureTrade(cont, first, second);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Exemple #3
0
        public void TestUpdateGoldSecureTrade(int gold, int plat, TradeFlag flag)
        {
            var cont = new Container(Serial.LastItem + 1);
            var data = new UpdateSecureTrade(cont, flag, gold, plat).Compile();

            Span <byte> expectedData = stackalloc byte[16];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x6F);   // Packet ID
            expectedData.Write(ref pos, (ushort)0x10); // Length
            expectedData.Write(ref pos, (byte)flag);   // Command
            expectedData.Write(ref pos, cont.Serial);
            expectedData.Write(ref pos, gold);
            expectedData.Write(ref pos, plat);

            AssertThat.Equal(data, expectedData);
        }
Exemple #4
0
        [InlineData(false, true)] // Update second
        public void TestUpdateSecureTrade(bool first, bool second)
        {
            var firstCont  = new Container(Serial.LastItem + 1);
            var secondCont = new Container(Serial.LastItem + 2);

            var cont = first ? firstCont : secondCont;
            var data = new UpdateSecureTrade(cont, first, second).Compile();

            Span <byte> expectedData = stackalloc byte[16];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x6F);             // Packet ID
            expectedData.Write(ref pos, (ushort)0x10);           // Length
            expectedData.Write(ref pos, (byte)TradeFlag.Update); // Command
            expectedData.Write(ref pos, cont.Serial);
            expectedData.Write(ref pos, first ? 1 : 0);          // true if first
            expectedData.Write(ref pos, second ? 1 : 0);         // true if second

            AssertThat.Equal(data, expectedData);
        }
Exemple #5
0
        public void TestUpdateGoldSecureTrade(int gold, int plat, TradeFlag flag)
        {
            var         cont         = new Container(Serial.LastItem + 1);
            Span <byte> data         = new UpdateSecureTrade(cont, flag, gold, plat).Compile();
            Span <byte> expectedData = stackalloc byte[]
            {
                0x6F,                   // Packet ID
                0x00, 0x10,             // Length
                (byte)flag,             // Command
                0x00, 0x00, 0x00, 0x00, // Container Serial
                0x00, 0x00, 0x00, 0x00, // Gold
                0x00, 0x00, 0x00, 0x00  // Platinum
            };

            int pos = 4;

            cont.Serial.CopyTo(ref pos, expectedData);
            gold.CopyTo(ref pos, expectedData);
            plat.CopyTo(ref pos, expectedData);

            AssertThat.Equal(data, expectedData);
        }
Exemple #6
0
        [InlineData(false, true)] // Update second
        public void TestUpdateSecureTrade(bool first, bool second)
        {
            var firstCont  = new Container(Serial.LastItem + 1);
            var secondCont = new Container(Serial.LastItem + 2);

            Container   cont = first ? firstCont : secondCont;
            Span <byte> data = new UpdateSecureTrade(cont, first, second).Compile();

            Span <byte> expectedData = stackalloc byte[]
            {
                0x6F,                                              // Packet ID
                0x00, 0x10,                                        // Length
                (byte)TradeFlag.Update,                            // Command
                0x00, 0x00, 0x00, 0x00,                            // Container Serial
                0x00, 0x00, 0x00, first ? (byte)0x01 : (byte)0x00, // (int)1 if first
                0x00, 0x00, 0x00, second ? (byte)0x01 : (byte)0x00 // (int)1 if second
            };

            cont.Serial.CopyTo(expectedData.Slice(4, 4));

            AssertThat.Equal(data, expectedData);
        }