public async Task Should_return_429_status_code_if_blocked() { sut.FilterDefinition = new ApiCostsAttribute(1); SetupApp(); A.CallTo(() => usageGate.IsBlockedAsync(appEntity, A <string> ._, DateTime.Today)) .Returns(true); await sut.OnActionExecutionAsync(actionContext, next); Assert.Equal(429, (actionContext.Result as StatusCodeResult)?.StatusCode); Assert.False(isNextCalled); }
public async Task Should_return_429_status_code_if_max_calls_over_blocking_limit() { sut.FilterDefinition = new ApiCostsAttribute(1); SetupApp(); apiCallsCurrent = 1000; apiCallsBlocking = 600; await sut.OnActionExecutionAsync(actionContext, next); Assert.Equal(429, (actionContext.Result as StatusCodeResult)?.StatusCode); Assert.False(isNextCalled); }
public async Task Should_return_429_status_code_if_max_calls_over_limit() { sut.FilterDefinition = new ApiCostsAttribute(1); SetupApp(); apiCallsCurrent = 1000; apiCallsMax = 600; await sut.OnActionExecutionAsync(actionContext, next); Assert.Equal(429, (actionContext.Result as StatusCodeResult).StatusCode); Assert.False(isNextCalled); A.CallTo(() => usageTracker.TrackAsync(A <string> .Ignored, A <string> .Ignored, A <double> .Ignored, A <double> .Ignored)) .MustNotHaveHappened(); }