コード例 #1
0
            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);
            }
コード例 #2
0
            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);
コード例 #3
0
            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>());
            }