public void HappyPath() { // When a rate limit context instance is created var context = new RateLimitContext(1, 10, HttpStatusCode.ServiceUnavailable, "source"); // Then it should create the expected rate limit context context.Remaining.Should().Be(1); context.Limit.Should().Be(10); context.HttpStatusCode.Should().Be(HttpStatusCode.ServiceUnavailable); context.Source.Should().Be("source"); }
public async void HappyPath() { // Given var formatter = new DefaultHttpResponseFormatter(); var rateLimitContext = new RateLimitContext(10, 20, HttpStatusCode.ServiceUnavailable, "source"); var httpContext = new DefaultHttpContext(); httpContext.Request.ContentType = "application/json"; // When formatter is executed await formatter.FormatAsync(httpContext, rateLimitContext); // Then it should set the response content type to request content type httpContext.Response.ContentType.Should().Be(httpContext.Request.ContentType); // And it should set the response status code to configured HTTP status code httpContext.Response.StatusCode.Should().Be((int)rateLimitContext.HttpStatusCode); }
public Task FormatAsync(HttpContext httpContext, RateLimitContext rateLimitContext) { throw new NotImplementedException(); }