ProtoTest.Devices
1.1.6
dotnet add package ProtoTest.Devices --version 1.1.6
NuGet\Install-Package ProtoTest.Devices -Version 1.1.6
<PackageReference Include="ProtoTest.Devices" Version="1.1.6" />
<PackageVersion Include="ProtoTest.Devices" Version="1.1.6" />
<PackageReference Include="ProtoTest.Devices" />
paket add ProtoTest.Devices --version 1.1.6
#r "nuget: ProtoTest.Devices, 1.1.6"
#:package ProtoTest.Devices@1.1.6
#addin nuget:?package=ProtoTest.Devices&version=1.1.6
#tool nuget:?package=ProtoTest.Devices&version=1.1.6
ProtoTest.Devices
Preview: the surface can change before 1.2.
Talk to devices - simulators or hardware - from the same test context, lifecycle and trace. A suite declares a named device client once and gets typed device instances per test by id.
dotnet add package ProtoTest.Devices
dotnet add package ProtoTest.Devices.WebSocket # ws:// and wss:// endpoints
dotnet add package ProtoTest.Devices.WebSocket.AspNetCore # in-process endpoints, no socket
dotnet add package ProtoTest.Devices.Mqtt # MQTT publish/subscribe
dotnet add package ProtoTest.Devices.Mqtt.Testcontainers # a Mosquitto broker owned by the run
dotnet add package ProtoTest.Devices.Tcp # raw TCP, connecting out or listening
dotnet add package ProtoTest.Devices.Serial # COM ports and /dev/tty lines
Includes
- Named device clients declared once, mirroring the REST and GraphQL builders:
devices.AddWebSocketClient("Chargers", path: "/ocpp/{deviceId}").AddDevice<AcCharger>()ordevices.AddMqttClient("Meters", "meters/{deviceId}/out", "meters/{deviceId}/in").AddDevice<FlowMeter>(). - Typed device classes: derive from
ProtoDevice, add domain methods, and compose the protectedConnectAsync,SendAsync,ReceiveAsyncandExpectAsyncprimitives. - Per-test instances through
Proto.Context.Devices("Chargers").For<AcCharger>("CP-001"), released with the test. - Addresses resolve per test: an explicit template (
{deviceId}filled in), a resolver, or the application's address when the client is registered insideAddApplication. - Per-client transport settings through
WithSetting, filled per device ({deviceId}included) and read by the transport throughDeviceEndpoint.Setting; a credential belongs here, not in the traced address. - Trace operations (
device.connect/send/receive/command) and adeviceentity with client, type, transport, address and connection state; the release path disconnects the device and records it. - Assertion-level coverage: a matched expectation records its message kind, and the client's protocol catalog reports kinds no test asserted as gaps.
- Stream framing for TCP, serial and custom stream transports:
DeviceFramers.Lines,Delimited,Enveloped,LengthPrefixedandFixedLength, set per client withWithFramer, andStreamDeviceConnectionfor a stream of your own. - Device messages as records: text (
DeviceMessage.Format/Parse, prefix, separator or fixed widths) or binary ([DeviceBinaryMessage],ToBytes/FromBytes), with[DeviceChecksum<T>](NMEA, CRC-16/Modbus, XOR, sum) and[DeviceFormat<T>]field formatters (DeviceFormatters: scaled, hex, Unix time, BCD).SendMessageAsync/ExpectMessageAsyncon the device, andDeviceMessageProtocolfor coverage per message type. ListenAsyncfor transports the system under test connects to, such asAddTcpListener.[RequiresDevice<TDevice>]skips tests the environment cannot run.
Limits
- One instance per (client, type, id) per test; devices are not shared across tests.
- One conversation per device instance: connect is single-flight, sends are serialized, one receive is in flight at a time, and a send racing a disconnect fails with a device error naming the device.
- An in-process endpoint needs
ProtoTest.Devices.WebSocket.AspNetCore; the socket transport reaches published addresses. A client is only routed through its own application's in-process transport. ExpectAsyncconsumes frames; the bounded exchange log is for failure messages.
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.1.6)
-
net8.0
- ProtoTest.Core (>= 1.1.6)
-
net9.0
- ProtoTest.Core (>= 1.1.6)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on ProtoTest.Devices:
| Package | Downloads |
|---|---|
|
ProtoTest.Devices.Serial
Serial transport for ProtoTest.Devices: talk to devices on a COM port or /dev/tty line with the same framing as the TCP transport. |
|
|
ProtoTest.Devices.Mqtt
MQTT transport for ProtoTest.Devices: talk to devices over publish/subscribe against a real broker. |
|
|
ProtoTest.Devices.WebSocket
WebSocket transport for ProtoTest.Devices: talk to devices over ws:// or wss://. |
|
|
ProtoTest.Devices.WebSocket.AspNetCore
In-process WebSocket device connections for ProtoTest: reach an application's endpoint through its TestServer, no socket. |
|
|
ProtoTest.Devices.Tcp
TCP transport for ProtoTest.Devices: talk to devices over a raw socket, connecting out or listening, with framing for line, delimited and length-prefixed protocols. |
GitHub repositories
This package is not used by any popular GitHub repositories.