public void TestBondStatus() { Serial petSerial = 0x1; var bonded = true; var data = new BondedStatus(petSerial, bonded).Compile(); Span <byte> expectedData = stackalloc byte[11]; var pos = 0; expectedData.Write(ref pos, (byte)0xBF); // Packet ID expectedData.Write(ref pos, (ushort)0x0B); // Length expectedData.Write(ref pos, (ushort)0x19); // Sub-packet #if NO_LOCAL_INIT expectedData.Write(ref pos, (byte)0); // Command #else pos++; #endif expectedData.Write(ref pos, petSerial); expectedData.Write(ref pos, bonded); AssertThat.Equal(data, expectedData); }
public void TestBondStatus() { Serial petSerial = 0x1; const bool bonded = true; var expected = new BondedStatus(petSerial, bonded).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendBondedStatus(petSerial, bonded); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }