public async Task StopShouldStopTheWorkerThread( [Frozen, Substitute] ITimer timer, [Frozen, Substitute] IGatewayService gateway, [Target] DefaultGatewayRxWorker rxWorker ) { await rxWorker.Start(gateway); await rxWorker.Stop(); await timer.Received().Stop(); }
public async Task SendShouldThrowIfTheGatewayWasStopped( string chunk, [Frozen, Substitute] IGatewayService gateway, [Target] DefaultGatewayRxWorker worker ) { var message = new GatewayMessageChunk { Bytes = Encoding.UTF8.GetBytes(chunk) }; var cancellationToken = new CancellationToken(false); await worker.Start(gateway); await worker.Stop(); var operationCancellationToken = new CancellationToken(false); Func <Task> func = () => worker.Emit(message, operationCancellationToken); await func.Should().ThrowAsync <OperationCanceledException>(); }