コード例 #1
0
 public TheStartMethod()
 {
     sinceParameters = Substitute.For <ISinceParameterRepository>();
     api             = Substitute.For <ITogglApi>();
     timeService     = Substitute.For <ITimeService>();
     leakyBucket     = Substitute.For <ILeakyBucket>();
     leakyBucket.TryClaimFreeSlots(Arg.Any <int>(), out _).Returns(true);
     rateLimiter = Substitute.For <IRateLimiter>();
     rateLimiter.WaitForFreeSlot().Returns(Observable.Return(Unit.Default));
     timeService.CurrentDateTime.Returns(now);
     state = new FetchAllSinceState(api, sinceParameters, timeService, leakyBucket, rateLimiter);
 }
コード例 #2
0
            public void ReturnsPreventServerOverloadWithCorrectDelayWhenTheLeakyBucketIsFull(TimeSpan delay)
            {
                leakyBucket.TryClaimFreeSlots(Arg.Any <int>(), out _)
                .Returns(x =>
                {
                    x[1] = delay;
                    return(false);
                });

                var transition = state.Start().SingleAsync().Wait();

                transition.Result.Should().Be(state.PreventOverloadingServer);
                var parameter = ((Transition <TimeSpan>)transition).Parameter;
            }