acpd_test 1.0.0 copy "acpd_test: ^1.0.0" to clipboard
acpd_test: ^1.0.0 copied to clipboard

Test utilities for acpd — in-memory transport pair, mock agent/client, and protocol fixtures.

acpd logo

acpd_test #

English · 简体中文

Deterministic test utilities for acpd.

Features #

  • MemoryTransportPair: two frame-aware transports wired back-to-back.
  • MemoryLineTransportPair: newline-delimited JSON transport pair for codec tests.
  • MockAgent and MockClient: programmable peers backed by real Connection instances.
  • Explicit close behavior suitable for unit and integration tests.

Usage #

import 'package:acpd/acpd.dart';
import 'package:acpd_test/acpd_test.dart';

final pair = MemoryTransportPair();
final client = ClientRole().connect(pair.left);
final agent = AgentRole()
    .handle('echo', (params, context) => params)
    .connect(pair.right);

try {
  final result = await client.connection.sendRequest<Map<String, Object?>>(
    'echo',
    params: const <String, Object?>{'value': 'hello'},
    mapResult: (value) => Map<String, Object?>.from(value! as Map),
  );
  print(result['value']);
} finally {
  await client.close();
  await agent.close();
  await pair.close();
}

See the package example/ for a complete runnable exchange.

License #

Apache License 2.0. See LICENSE.

0
likes
150
points
31
downloads

Documentation

Documentation
API reference

Publisher

verified publisherfluttercandies.com

Weekly Downloads

Test utilities for acpd — in-memory transport pair, mock agent/client, and protocol fixtures.

Homepage
Repository (GitHub)
View/report issues

Topics

#acp #agent #protocol #testing

License

Apache-2.0 (license)

Dependencies

acpd

More

Packages that depend on acpd_test