FakeTransportConnection class

An in-memory TransportConnection for tests that do not need a broker.

It starts disconnected. start connects it immediately. Use setStatus to simulate a drop, deliver to push a message to active subscriptions, and publishes to inspect what the bus tried to publish.

Implemented types

Constructors

FakeTransportConnection()

Properties

closed ↔ bool
getter/setter pair
errors → Stream<Object>
Asynchronous transport errors: a dropped connection, a failed publish, a failed reconnect attempt.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isConnected → bool
no setteroverride
publishes → List<FakeTransportPublish>
final
requests → List<FakeTransportRequest>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
status → TransportStatus
no setteroverride
statusStream → Stream<TransportStatus>
no setteroverride
subscribedSubjects → List<String>
The subjects of all subscriptions that have not been cancelled.
no setter

Methods

close() → Future<void>
override
deliver(TransportMessage message) → void
Delivers message to every active subscription whose subject pattern matches.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publish(String subject, Uint8List data, {Map<String, String>? arguments, String? originId, String? replyTo}) → void
Publishes a message. Throws TransportServerUnavailableException when the connection is not established. replyTo names the subject a response must be published to; it is a wire subject, not a local topic.
override
reportError(Object error) → void
Emits an asynchronous transport error.
request(String subject, Uint8List data, {Map<String, String>? arguments, String? originId, Duration? timeout}) → Future<TransportMessage>
Sends a request and waits for the first response.
override
setStatus(TransportStatus status) → void
Changes the connection state and emits it.
start() → Future<void>
Starts the first connection attempt. The returned future completes when that attempt finishes; reconnection continues in the background.
override
subscribe(String subject, void onMessage(TransportMessage message)) → TransportSubscription
Registers a subscription. When the connection is down the subscription is remembered and established after the next successful connection.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited