Beispiel #1
0
        public void Should_send_request_to_first_replica_with_correct_parameters()
        {
            var token = new CancellationTokenSource().Token;

            strategy.SendAsync(request, parameters, sender, budget, replicas, replicas.Length, token).Wait();

            sender.Received().SendToReplicaAsync(replicas[0], request, null, budget.Remaining, token);
        }
        public void Should_fire_initial_requests_with_whole_remaining_time_budget()
        {
            DropSynchronizationContext();

            strategy.SendAsync(request, sender, Budget.WithRemaining(5.Seconds()), replicas, replicas.Length, token);

            sender.Received(1).SendToReplicaAsync(replicas[0], request, 5.Seconds(), Arg.Any <CancellationToken>());
            sender.Received(1).SendToReplicaAsync(replicas[1], request, 5.Seconds(), Arg.Any <CancellationToken>());
            sender.Received(1).SendToReplicaAsync(replicas[2], request, 5.Seconds(), Arg.Any <CancellationToken>());
        }
        public void Should_send_request_to_each_replica_with_correct_timeout()
        {
            Send(Budget.Infinite);

            sender.ReceivedCalls().Should().HaveCount(3);
            sender.Received(1).SendToReplicaAsync(replica1, request, 1.Seconds(), token);
            sender.Received(1).SendToReplicaAsync(replica2, request, 2.Seconds(), token);
            sender.Received(1).SendToReplicaAsync(replica3, request, 3.Seconds(), token);
        }
Beispiel #4
0
        public void Should_pass_cancellation_token_to_base_request_sender()
        {
            var tokenSource = new CancellationTokenSource();

            CompleteSending();

            contextualSender.SendToReplicaAsync(replica, request, timeout, tokenSource.Token).GetAwaiter().GetResult();

            baseSender.Received().SendToReplicaAsync(replica, request, timeout, tokenSource.Token);
        }
Beispiel #5
0
        public void Should_fire_initial_requests_with_whole_remaining_time_budget()
        {
            strategy.SendAsync(request, parameters, sender, Budget.WithRemaining(5.Seconds()), replicas, replicas.Length, token);

            sender.Received(1).SendToReplicaAsync(replicas[0], request, Arg.Any <TimeSpan?>(), 5.Seconds(), Arg.Any <CancellationToken>());
            sender.Received(1).SendToReplicaAsync(replicas[1], request, Arg.Any <TimeSpan?>(), 5.Seconds(), Arg.Any <CancellationToken>());
            sender.Received(1).SendToReplicaAsync(replicas[2], request, Arg.Any <TimeSpan?>(), 5.Seconds(), Arg.Any <CancellationToken>());
        }
Beispiel #6
0
        public void Should_fire_initial_request_with_correct_parameters()
        {
            strategy.SendAsync(request, parameters, sender, Budget.WithRemaining(5.Seconds()), replicas, replicas.Length, token);

            sender.Received(1).SendToReplicaAsync(replicas[0], request, parameters.ConnectionTimeout, 5.Seconds(), Arg.Any <CancellationToken>());
        }