in src/Testing/Emulator/Policies/SetBodyHandler.cs [30:66]
public object? Handle(GatewayContext context, object?[]? args)
{
if (args is not { Length: 2 })
{
throw new ArgumentException("Expected 2 arguments", nameof(args));
}
if (args[0] is not string body)
{
throw new ArgumentException("SetBodyHandler requires a string argument.");
}
SetBodyConfig? config = null;
if (args[1] is not null)
{
if (args[1] is not SetBodyConfig c)
{
throw new ArgumentException("SetBodyHandler requires a string argument for the content type.");
}
config = c;
}
var callbackHook = CallbackHooks.Find(hook => hook.Item1(context, body, config));
if (callbackHook is not null)
{
callbackHook.Item2(context, body, config);
return null;
}
var contextBody = GetBody(context);
contextBody.Content = body;
return null;
}