mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-18 23:58:14 +08:00
Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
@ -2,9 +2,8 @@
|
||||
|
||||
namespace Ocelot.UnitTests.RateLimit
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
@ -12,13 +11,14 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.RateLimit;
|
||||
using Ocelot.RateLimit.Middleware;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
public class ClientRateLimitMiddlewareTests
|
||||
{
|
||||
@ -55,13 +55,13 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
var downstreamReRoute = new DownstreamReRouteBuilder()
|
||||
.WithEnableRateLimiting(true)
|
||||
.WithRateLimitOptions(new RateLimitOptions(true, "ClientId", new List<string>(), false, "", "", new RateLimitRule("1s", 100, 3), 429))
|
||||
.WithUpstreamHttpMethod(new List<string> {"Get"})
|
||||
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
||||
.WithUpstreamPathTemplate(upstreamTemplate)
|
||||
.Build();
|
||||
|
||||
var reRoute = new ReRouteBuilder()
|
||||
.WithDownstreamReRoute(downstreamReRoute)
|
||||
.WithUpstreamHttpMethod(new List<string> {"Get"})
|
||||
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
||||
.Build();
|
||||
|
||||
var downstreamRoute = new DownstreamRoute(new List<Ocelot.DownstreamRouteFinder.UrlMatcher.PlaceholderNameAndValue>(), reRoute);
|
||||
@ -102,8 +102,8 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
|
||||
private void WhenICallTheMiddlewareMultipleTime(int times)
|
||||
{
|
||||
var clientId = "ocelotclient1";
|
||||
|
||||
var clientId = "ocelotclient1";
|
||||
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), _url);
|
||||
@ -117,8 +117,8 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
|
||||
private void WhenICallTheMiddlewareWithWhiteClient()
|
||||
{
|
||||
var clientId = "ocelotclient2";
|
||||
|
||||
var clientId = "ocelotclient2";
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), _url);
|
||||
@ -127,10 +127,10 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
_downstreamContext.HttpContext.Request.Headers.TryAdd("ClientId", clientId);
|
||||
|
||||
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
|
||||
_responseStatusCode = (int)_downstreamContext.HttpContext.Response.StatusCode;
|
||||
}
|
||||
}
|
||||
|
||||
_responseStatusCode = (int)_downstreamContext.HttpContext.Response.StatusCode;
|
||||
}
|
||||
}
|
||||
|
||||
private void ThenresponseStatusCodeIs429()
|
||||
{
|
||||
_responseStatusCode.ShouldBe(429);
|
||||
@ -142,7 +142,7 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
}
|
||||
}
|
||||
|
||||
class FakeStream : Stream
|
||||
internal class FakeStream : Stream
|
||||
{
|
||||
public override void Flush()
|
||||
{
|
||||
@ -175,4 +175,4 @@ namespace Ocelot.UnitTests.RateLimit
|
||||
public override long Length { get; }
|
||||
public override long Position { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user