public async Task StopShouldStopTheTxWorker( [Frozen, Substitute] IGatewayTxWorker txWorker, [Target] DefaultGatewayService gateway ) { await gateway.StartAsync(); await gateway.StopAsync(); await txWorker.Received().Stop(); }
public async Task StopShouldAbortTheWebSocket( [Frozen, Substitute] IClientWebSocket clientWebSocket, [Target] DefaultGatewayService gateway ) { await gateway.StartAsync(); await gateway.StopAsync(); clientWebSocket.Received().Abort(); }
public async Task RunShouldThrowIfTheGatewayWasStopped( [Target] DefaultGatewayService gateway ) { var cancellationToken = new CancellationToken(false); await gateway.StartAsync(); await gateway.StopAsync(); Func <Task> func = () => gateway.Run(); await func.Should().ThrowAsync <OperationCanceledException>(); }
public async Task StopShouldSetIsReadyToFalse( [Frozen, Substitute] IGatewayTxWorker txWorker, [Frozen, Substitute] IGatewayUtilsFactory factory, [Target] DefaultGatewayService gateway ) { gateway.IsReady = true; await gateway.StartAsync(); await gateway.StopAsync(); gateway.IsReady.Should().BeFalse(); }
public async Task ShouldThrowIfGatewayWasStopped( uint interval, [Target] DefaultGatewayService gateway ) { var cancellationToken = new CancellationToken(false); await gateway.StartAsync(); await gateway.StopAsync(); Func <Task> func = () => gateway.StartHeartbeat(interval); await func.Should().ThrowAsync <OperationCanceledException>(); }
public async Task SendShouldThrowIfTheGatewayWasStopped( int sequenceNumber, [Frozen, Substitute] IGatewayTxWorker txWorker, [Target] DefaultGatewayService gateway ) { var message = new GatewayMessage { SequenceNumber = sequenceNumber }; var cancellationToken = new CancellationToken(false); await gateway.StartAsync(); await gateway.StopAsync(); var operationCancellationToken = new CancellationToken(false); Func <Task> func = () => gateway.Send(message, operationCancellationToken); await func.Should().ThrowAsync <OperationCanceledException>(); }
public async Task StopShouldStopTheHeartbeat( ITimer heartbeat, [Frozen, Substitute] ITimerFactory timerFactory, [Frozen, Substitute] IGatewayTxWorker txWorker, [Frozen, Substitute] IGatewayUtilsFactory factory, [Target] DefaultGatewayService gateway ) { var cancellationToken = new CancellationToken(false); timerFactory.CreateTimer(Any <AsyncTimerCallback>(), Any <int>(), Is("Heartbeat")).Returns(heartbeat); await gateway.StartAsync(); await gateway.StartHeartbeat(10); await gateway.StopAsync(); await heartbeat.Received().Stop(); }