using System;
using Server.Network;
namespace Server.Tests.Network;
public static class PacketAssert
{
///
/// Asserts that writes exactly the bytes of the reference
/// packet to a fresh test NetState negotiated with .
///
public static void Sends(Packet expected, Action send, ProtocolChanges changes = ProtocolChanges.None) =>
Sends(_ => expected, send, changes);
///
/// As , for a reference packet that depends on
/// the negotiated NetState. It is built after is applied and before the send.
///
public static void Sends(
Func expected, Action send, ProtocolChanges changes = ProtocolChanges.None
)
{
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = changes;
var expectedBytes = expected(ns).Compile();
send(ns);
AssertThat.Equal(ns.SendBuffer.GetReadSpan(), expectedBytes);
}
}