public async Task ShouldStartHeartbeat( uint interval, [Frozen, Substitute] IGatewayService gateway, [Target] HelloEventController controller ) { var cancellationToken = new CancellationToken(false); var @event = new HelloEvent { HeartbeatInterval = interval }; await controller.Handle(@event, cancellationToken); await gateway.Received().StartHeartbeat(interval); }
public async Task ShouldResumeIfBothSessionIdAndSequenceNumberAreNotNull( string sessionId, int sequenceNumber, [Frozen, Options] IOptions <GatewayOptions> options, [Frozen, Substitute] IGatewayService gateway, [Target] HelloEventController controller ) { gateway.SessionId = sessionId; gateway.SequenceNumber = sequenceNumber; var cancellationToken = new CancellationToken(false); var @event = new HelloEvent { }; await controller.Handle(@event, cancellationToken); await gateway.ReceivedWithAnyArgs().Send(default, default);
public async Task ShouldThrowIfCanceled( uint interval, [Frozen, Substitute] IGatewayService gateway, [Target] HelloEventController controller ) { var cancellationToken = new CancellationToken(true); var @event = new HelloEvent { HeartbeatInterval = interval }; Func <Task> func = () => controller.Handle(@event, cancellationToken); await func.Should().ThrowAsync <OperationCanceledException>(); await gateway.DidNotReceive().StartHeartbeat(Any <uint>()); }