public void TestDisplaySecureTrade(string name) { var m = new Mobile(0x1); m.DefaultMobileInit(); var firstCont = new Container(Serial.LastItem + 1); var secondCont = new Container(Serial.LastItem + 2); Span <byte> data = new DisplaySecureTrade(m, firstCont, secondCont, name).Compile(); Span <byte> expectedData = stackalloc byte[] { 0x6F, // Packet ID 0x00, 0x2F, // Length (byte)TradeFlag.Display, // Command 0x00, 0x00, 0x00, 0x00, // Mobile Serial 0x00, 0x00, 0x00, 0x00, // First Container Serial 0x00, 0x00, 0x00, 0x00, // Second Container Serial 0x01, // true if has name 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Name 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; int pos = 4; m.Serial.CopyTo(ref pos, expectedData); firstCont.Serial.CopyTo(ref pos, expectedData); secondCont.Serial.CopyTo(ref pos, expectedData); pos++; name.CopyASCIITo(ref pos, 30, expectedData); AssertThat.Equal(data, expectedData); }
public void TestDisplaySecureTrade(string name) { var m = new Mobile(0x1); m.DefaultMobileInit(); var firstCont = new Container(Serial.LastItem + 1); var secondCont = new Container(Serial.LastItem + 2); var data = new DisplaySecureTrade(m, firstCont, secondCont, name).Compile(); var hasName = name.Length > 0; Span <byte> expectedData = stackalloc byte[17 + (hasName ? 30 : 0)]; var pos = 0; expectedData.Write(ref pos, (byte)0x6F); // Packet ID expectedData.Write(ref pos, (ushort)0x2F); // Length expectedData.Write(ref pos, (byte)TradeFlag.Display); // Command expectedData.Write(ref pos, m.Serial); expectedData.Write(ref pos, firstCont.Serial); expectedData.Write(ref pos, secondCont.Serial); expectedData.Write(ref pos, hasName); if (hasName) { expectedData.WriteAsciiFixed(ref pos, name, 30); } AssertThat.Equal(data, expectedData); }
public void TestDisplaySecureTrade(string name) { var m = new Mobile(0x1); m.DefaultMobileInit(); var firstCont = new Container(World.NewItem); var secondCont = new Container(World.NewItem); var expected = new DisplaySecureTrade(m, firstCont, secondCont, name).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendDisplaySecureTrade(m, firstCont, secondCont, name); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }