ProtoTest.Messaging
1.0.0
See the version list below for details.
dotnet add package ProtoTest.Messaging --version 1.0.0
NuGet\Install-Package ProtoTest.Messaging -Version 1.0.0
<PackageReference Include="ProtoTest.Messaging" Version="1.0.0" />
<PackageVersion Include="ProtoTest.Messaging" Version="1.0.0" />
<PackageReference Include="ProtoTest.Messaging" />
paket add ProtoTest.Messaging --version 1.0.0
#r "nuget: ProtoTest.Messaging, 1.0.0"
#:package ProtoTest.Messaging@1.0.0
#addin nuget:?package=ProtoTest.Messaging&version=1.0.0
#tool nuget:?package=ProtoTest.Messaging&version=1.0.0
ProtoTest.Messaging
Publish messages and await the one that matters, with a predicate and a timeout, over a broker capability.
dotnet add package ProtoTest.Messaging
Quick start
builder.AddMessaging();
// Publish a command the application consumes.
await Proto.Context.Messaging().PublishAsync("invoices-create", """{"id":42}""");
// Await the event the application emits; failing to arrive is a real failure.
var message = await Proto.Context.Messaging().AwaitAsync(
"invoice.paid",
candidate => candidate.Payload!.Contains("\"id\":42"));
message.ShouldMatchShape(Proto.Context, new { id = 42, status = "Paid" });
What it adds
- Client —
Proto.Context.Messaging()withPublishAsync(destination, payload?, headers?, contentType?)andAwaitAsync(destination, predicate, timeout?); without a timeout the configured default applies. - Brokers —
AddMessaging(messaging => messaging.UseBroker(...))attaches an adapter; with none, an in-memory double serves the run and registers noBrokercapability, so[RequiresCapability(ProtoCapabilityKinds.Broker)]skips where no real broker exists. - Assertion —
message.ShouldMatchShape(Proto.Context, shape)recordsassert.json.shapeand amessaging.contract.shapeobservation, naming the destination when the payload is empty or not JSON. - Capture —
CaptureAttachments()records redacted published and matched payloads asmessage-publish-…/message-receive-…attachments; a capture failure is amessaging.attachment.failedevent and never fails the operation. - Tracing —
messaging.publish/messaging.awaitoperations andmessaging.publish/messaging.receiveobservations; the broker is a run-scoped resource.
Configuration
| Key | Type | Default |
|---|---|---|
ProtoTest:Messaging:DefaultTimeout |
TimeSpan |
00:00:10 |
ProtoTest:Messaging:Destinations |
IList<string> |
empty |
ProtoTest:Messaging:Attachments:CapturePublishedPayloads |
bool |
true |
ProtoTest:Messaging:Attachments:CaptureReceivedPayloads |
bool |
true |
ProtoTest:Messaging:Attachments:RedactSensitiveData |
bool |
true |
ProtoTest:Messaging:Attachments:MaxDiagnosticBodyLength |
int |
65536 |
ProtoTest:Messaging:Attachments:SensitiveJsonProperties |
List<string> |
password, token, access_token, refresh_token, secret, apiKey, api_key |
The in-memory double only sees messages published after its consumer starts, payloads are UTF-8 strings only, and the package ships no collector, so observations reach a report only through one.
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ProtoTest.Core (>= 1.0.0)
- ProtoTest.Json (>= 1.0.0)
-
net8.0
- ProtoTest.Core (>= 1.0.0)
- ProtoTest.Json (>= 1.0.0)
-
net9.0
- ProtoTest.Core (>= 1.0.0)
- ProtoTest.Json (>= 1.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ProtoTest.Messaging:
| Package | Downloads |
|---|---|
|
ProtoTest.Messaging.RabbitMq
RabbitMQ adapter for the ProtoTest messaging capability: publish to exchanges and tap events with a per-test queue. |
|
|
ProtoTest.Messaging.MassTransit
MassTransit bridge for the ProtoTest messaging capability: publish and await messages over the application's in-process ITestHarness. |
GitHub repositories
This package is not used by any popular GitHub repositories.