mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 16:18:14 +08:00
Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
@ -1,31 +1,37 @@
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Cache;
|
||||
using Ocelot.Middleware;
|
||||
using Shouldly;
|
||||
using System.Net.Http;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Cache {
|
||||
public class CacheKeyGeneratorTests {
|
||||
namespace Ocelot.UnitTests.Cache
|
||||
{
|
||||
public class CacheKeyGeneratorTests
|
||||
{
|
||||
private readonly ICacheKeyGenerator _cacheKeyGenerator;
|
||||
private readonly DownstreamContext _downstreamContext;
|
||||
|
||||
public CacheKeyGeneratorTests() {
|
||||
public CacheKeyGeneratorTests()
|
||||
{
|
||||
_cacheKeyGenerator = new CacheKeyGenerator();
|
||||
_cacheKeyGenerator = new CacheKeyGenerator();
|
||||
_downstreamContext = new DownstreamContext(new DefaultHttpContext()) {
|
||||
_downstreamContext = new DownstreamContext(new DefaultHttpContext())
|
||||
{
|
||||
DownstreamRequest = new Ocelot.Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"))
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_generate_cache_key_from_context() {
|
||||
public void should_generate_cache_key_from_context()
|
||||
{
|
||||
this.Given(x => x.GivenCacheKeyFromContext(_downstreamContext))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenCacheKeyFromContext(DownstreamContext context) {
|
||||
private void GivenCacheKeyFromContext(DownstreamContext context)
|
||||
{
|
||||
string generatedCacheKey = _cacheKeyGenerator.GenerateRequestCacheKey(context);
|
||||
string cachekey = MD5Helper.GenerateMd5("GET-https://some.url/blah?abcd=123");
|
||||
generatedCacheKey.ShouldBe(cachekey);
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace Ocelot.UnitTests.Cache
|
||||
{
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Ocelot.Cache;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Xunit;
|
||||
|
||||
public class InMemoryCacheTests
|
||||
@ -68,7 +68,7 @@
|
||||
result.ShouldBeNull();
|
||||
}
|
||||
|
||||
class Fake
|
||||
private class Fake
|
||||
{
|
||||
public Fake(int value)
|
||||
{
|
||||
|
@ -1,9 +1,5 @@
|
||||
namespace Ocelot.UnitTests.Cache
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Moq;
|
||||
using Ocelot.Cache;
|
||||
@ -13,15 +9,18 @@
|
||||
using Ocelot.DownstreamRouteFinder;
|
||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Middleware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using System.Net;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
|
||||
public class OutputCacheMiddlewareTests
|
||||
{
|
||||
private readonly Mock<IOcelotCache<CachedResponse>> _cache;
|
||||
private readonly Mock<IOcelotCache<CachedResponse>> _cache;
|
||||
private readonly Mock<IOcelotLoggerFactory> _loggerFactory;
|
||||
private Mock<IOcelotLogger> _logger;
|
||||
private OutputCacheMiddleware _middleware;
|
||||
@ -30,7 +29,6 @@
|
||||
private readonly ICacheKeyGenerator _cacheKeyGenerator;
|
||||
private CachedResponse _response;
|
||||
|
||||
|
||||
public OutputCacheMiddlewareTests()
|
||||
{
|
||||
_cache = new Mock<IOcelotCache<CachedResponse>>();
|
||||
@ -119,7 +117,7 @@
|
||||
.Build())
|
||||
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
||||
.Build();
|
||||
|
||||
|
||||
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(), reRoute);
|
||||
|
||||
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Cache;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -44,15 +42,15 @@ namespace Ocelot.UnitTests.Cache
|
||||
.When(_ => WhenICreateTheRegion())
|
||||
.Then(_ => ThenTheRegionIs("region"))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GivenTheReRoute(FileReRoute reRoute)
|
||||
{
|
||||
_reRoute = reRoute;
|
||||
}
|
||||
|
||||
private void WhenICreateTheRegion()
|
||||
{
|
||||
{
|
||||
RegionCreator regionCreator = new RegionCreator();
|
||||
_result = regionCreator.Create(_reRoute);
|
||||
}
|
||||
@ -62,4 +60,4 @@ namespace Ocelot.UnitTests.Cache
|
||||
_result.ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user