FakeIndiServer class final Testing

An in-process INDI server for testing applications without hardware.

It plays the part of indiserver and its drivers: it answers getProperties with the properties you define, applies new*Vector commands and answers with set*Vector, honors enableBLOB, and answers pings. Connection failures can be simulated with dropConnections and refuseConnections.

final server = FakeIndiServer()
  ..define(DefSwitchVector(
    device: 'Mount',
    name: 'CONNECTION',
    rule: SwitchRule.oneOfMany,
    elements: const [
      DefSwitch(name: 'CONNECT', state: SwitchState.off),
      DefSwitch(name: 'DISCONNECT', state: SwitchState.on),
    ],
  ));
final client = IndiClient.withTransport(server.transport);
await client.connect();

Constructors

FakeIndiServer({FakeCommandHandler? onNewVector})
Creates a server. onNewVector customizes how commands are answered.

Properties

answerPings ↔ bool
Whether pingRequest is answered, like indiserver 2.x. Set to false to simulate an older server.
getter/setter pair
connections → List<FakeServerConnection>
The open connections.
no setter
devices → Set<String>
The names of the devices defined.
no setter
hashCode → int
The hash code for this object.
no setterinherited
onNewVector ↔ FakeCommandHandler?
Customizes how new*Vector commands are answered.
getter/setter pair
received → Stream<IndiCommand>
Every command received from any client.
no setter
refuseConnections ↔ bool
Whether new connections are refused, as if the server were down.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transport ↔ InMemoryTransport
The transport to give to IndiClient.withTransport.
latefinal

Methods

close() → Future<void>
Closes every connection and stops the server.
define(DefVector<DefElement> definition) → void
Defines (or redefines) a property and announces it to connected clients that asked for it.
definition(String device, String property) → DefVector<DefElement>?
The current definition of property of device, with the latest values applied.
delete(String device, [String? property]) → void
Deletes a property, or a whole device when property is null, and tells connected clients.
dropConnections() → Future<void>
Closes every connection, as if the network failed. Clients see the connection lost and start reconnecting.
message(String text, {String? device}) → void
Sends a message to connected clients.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
update(SetVector<OneElement> update) → void
Sends an update to connected clients and records the new values.

Operators

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