public void TestSetArrow(int x, int y) { var expected = new SetArrow(x, y).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendSetArrow(x, y, Serial.Zero); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
public void TestSetArrow(int x, int y) { var data = new SetArrow(x, y).Compile(); Span <byte> expectedData = stackalloc byte[6]; var pos = 0; expectedData.Write(ref pos, (byte)0xBA); // Packet ID expectedData.Write(ref pos, (byte)0x01); // Command expectedData.Write(ref pos, (ushort)x); expectedData.Write(ref pos, (ushort)y); AssertThat.Equal(data, expectedData); }
public void TestSetArrow(int x, int y) { Span <byte> data = new SetArrow(x, y).Compile(); Span <byte> expectedData = stackalloc byte[] { 0xBA, // Packet 0x01, // Command 0x00, 0x00, // X 0x00, 0x00 // Y }; ((ushort)x).CopyTo(expectedData.Slice(2, 2)); ((ushort)y).CopyTo(expectedData.Slice(4, 2)); AssertThat.Equal(data, expectedData); }