Merge branch 'develop' into feature/#238-statefull

This commit is contained in:
TomPallister
2018-03-03 17:12:41 +00:00
137 changed files with 493 additions and 440 deletions

View File

@ -6,24 +6,17 @@ namespace Ocelot.UnitTests.Authentication
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Authentication.Middleware;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class AuthenticationMiddlewareTests
{
private OkResponse<DownstreamRoute> _downstreamRoute;
private AuthenticationMiddleware _middleware;
private Mock<IOcelotLoggerFactory> _factory;
private Mock<IOcelotLogger> _logger;
@ -49,7 +42,7 @@ namespace Ocelot.UnitTests.Authentication
.BDDfy();
}
private void WhenICallTheMiddleware()
private void WhenICallTheMiddleware()
{
_next = async (context) => {
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
@ -89,7 +82,7 @@ namespace Ocelot.UnitTests.Authentication
{
string text = reader.ReadToEnd();
return text;
};
}
}
}
}

View File

@ -28,7 +28,6 @@ namespace Ocelot.UnitTests.Authorization
this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
{
new Claim("UserType", "registered"),
}))))
.And(x => x.GivenARouteClaimsRequirement(new Dictionary<string, string>
{

View File

@ -1,5 +1,4 @@
using Ocelot.Errors;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
namespace Ocelot.UnitTests.Cache
@ -11,26 +10,19 @@ namespace Ocelot.UnitTests.Cache
using Shouldly;
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Cache;
using Ocelot.Cache.Middleware;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
using Ocelot.DownstreamRouteFinder.Middleware;
using Microsoft.AspNetCore.Http;
public class OutputCacheMiddlewareRealCacheTests
{
private IOcelotCache<CachedResponse> _cacheManager;
private CachedResponse _response;
private OutputCacheMiddleware _middleware;
private DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;

View File

@ -110,7 +110,6 @@ namespace Ocelot.UnitTests.Cache
private void GivenThereAreNoErrors()
{
_downstreamContext.Errors = new List<Error>();
}
private void ThenTheCacheGetIsCalledCorrectly()

View File

@ -93,7 +93,6 @@ namespace Ocelot.UnitTests.Claims
.BDDfy();
}
private void GivenClaimsToThings(List<ClaimToThing> configuration)
{
_claimsToThings = configuration;
@ -129,7 +128,6 @@ namespace Ocelot.UnitTests.Claims
private void ThenTheResultIsError()
{
_result.IsError.ShouldBe(true);
}

View File

@ -15,12 +15,10 @@ namespace Ocelot.UnitTests.Claims
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
using Ocelot.DownstreamRouteFinder.Middleware;
public class ClaimsBuilderMiddlewareTests
{
private readonly Mock<IAddClaimsToRequest> _addHeaders;
private Response<DownstreamRoute> _downstreamRoute;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private readonly ClaimsBuilderMiddleware _middleware;
@ -68,7 +66,6 @@ namespace Ocelot.UnitTests.Claims
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
}
private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute)
{
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;

View File

@ -79,6 +79,7 @@ namespace Ocelot.UnitTests.Configuration
{
_result.Count.ShouldBeGreaterThan(0);
}
private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
{
_claimsToThings = claimsToThings;
@ -107,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
}
}
}
}

View File

@ -588,7 +588,8 @@ namespace Ocelot.UnitTests.Configuration
AuthenticationOptions = new FileAuthenticationOptions()
{
AuthenticationProviderKey = "Test"
} }
}
}
}
}))
.When(x => x.WhenIValidateTheConfiguration())
@ -869,7 +870,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Theory]
[InlineData(null)]
[InlineData("")]
@ -981,7 +981,8 @@ namespace Ocelot.UnitTests.Configuration
.And(x => x.ThenTheErrorMessageAtPositionIs(0, "When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!"))
.BDDfy();
}
[Fact]
[Fact]
public void configuration_is_not_valid_when_host_and_port_is_empty()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration
@ -1007,7 +1008,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
private void GivenAConfiguration(FileConfiguration fileConfiguration)
{
_fileConfiguration = fileConfiguration;

View File

@ -12,7 +12,6 @@ using Xunit;
using Shouldly;
using static Ocelot.UnitTests.Wait;
namespace Ocelot.UnitTests.Configuration
{
public class ConsulFileConfigurationPollerTests : IDisposable
@ -34,6 +33,7 @@ namespace Ocelot.UnitTests.Configuration
_repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse<FileConfiguration>(_fileConfig));
_poller = new ConsulFileConfigurationPoller(_factory.Object, _repo.Object, _setter.Object);
}
public void Dispose()
{
_poller.Dispose();
@ -49,7 +49,6 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_call_setter_when_gets_new_config()
{
var newConfig = new FileConfiguration {
ReRoutes = new List<FileReRoute>
{
@ -84,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration
_setter.Verify(x => x.Set(fileConfig), Times.Once);
return true;
}
catch(Exception ex)
catch(Exception)
{
return false;
}

View File

@ -502,7 +502,6 @@ namespace Ocelot.UnitTests.Configuration
.WithUseServiceDiscovery(false)
.Build();
this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -545,7 +544,6 @@ namespace Ocelot.UnitTests.Configuration
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("(?i)/api/products/.*/$", 1))
.Build();
this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -823,8 +821,7 @@ namespace Ocelot.UnitTests.Configuration
result.DownstreamReRoute[0].ClaimsToClaims.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToClaims.Count);
result.DownstreamReRoute[0].ClaimsToHeaders.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToHeaders.Count);
result.DownstreamReRoute[0].ClaimsToQueries.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToQueries.Count);
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
}
}
@ -916,7 +913,6 @@ namespace Ocelot.UnitTests.Configuration
.Setup(x => x.Create(It.IsAny<FileGlobalConfiguration>())).Returns(serviceProviderConfiguration);
}
private void GivenTheFollowingRegionIsReturned(string region)
{
_regionCreator

View File

@ -38,8 +38,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
{
_fileConfiguration = fileConfiguration;
@ -59,4 +57,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.Get(), Times.Once);
}
}
}
}

View File

@ -111,7 +111,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
{
var configurationPath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";

View File

@ -48,7 +48,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_return_error_if_unable_to_set_file_configuration()
{
@ -110,4 +109,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.AddOrReplace(_configuration.Data), Times.Once);
}
}
}
}

View File

@ -33,13 +33,11 @@ namespace Ocelot.UnitTests.Configuration
UpstreamHeaderTransform = new Dictionary<string, string>
{
{"Test", "Test, Chicken"},
{"Moop", "o, a"}
},
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Pop", "West, East"},
{"Bop", "e, r"}
}
};
@ -86,7 +84,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_use_base_url_partial_placeholder()
{
@ -155,4 +152,4 @@ namespace Ocelot.UnitTests.Configuration
}
}
}
}
}

View File

@ -7,7 +7,6 @@ using Xunit;
namespace Ocelot.UnitTests.Configuration
{
public class HttpHandlerOptionsCreatorTests
{
private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_match_forward_slash_or_no_forward_slash_if_template_end_with_forward_slash()
{
@ -70,7 +69,7 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_create_template_pattern_that_matches_anything_to_end_of_string()
{
var fileReRoute = new FileReRoute
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/api/products/{productId}",
ReRouteIsCaseSensitive = true
@ -181,4 +180,4 @@ namespace Ocelot.UnitTests.Configuration
_result.Priority.ShouldBe(v);
}
}
}
}

View File

@ -111,7 +111,6 @@ namespace Ocelot.UnitTests.Controllers
.BDDfy();
}
private void ThenTheNodeIsCalledCorrectly()
{
_node.Verify(x => x.Accept(It.IsAny<UpdateFileConfiguration>()), Times.Once);

View File

@ -15,7 +15,6 @@ using Ocelot.DependencyInjection;
using Ocelot.Requester;
using Ocelot.UnitTests.Requester;
using Shouldly;
using System;
using IdentityServer4.AccessTokenValidation;
using TestStack.BDDfy;
using Xunit;
@ -38,6 +37,7 @@ namespace Ocelot.UnitTests.DependencyInjection
_services.AddSingleton<IConfiguration>(_configRoot);
_maxRetries = 100;
}
private Exception _ex;
[Fact]
@ -69,7 +69,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_cache_manager()
{
@ -102,9 +101,7 @@ namespace Ocelot.UnitTests.DependencyInjection
[Fact]
public void should_set_up_administration_with_identity_server_options()
{
Action<IdentityServerAuthenticationOptions> options = o => {
};
Action<IdentityServerAuthenticationOptions> options = o => {};
this.Given(x => WhenISetUpOcelotServices())
.When(x => WhenISetUpAdministration(options))
@ -152,7 +149,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_without_passing_in_config()
{

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
_downstreamRouteFinder = new Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder(_mockMatcher.Object, _finder.Object);
}
[Fact]
public void should_return_highest_priority_when_first()
{
@ -182,7 +181,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.BDDfy();
}
[Fact]
public void should_not_append_slash_to_upstream_url_path()
{
@ -598,7 +596,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.BDDfy();
}
[Fact]
public void should_return_route_when_host_matches_but_null_host_on_same_path_first()
{

View File

@ -30,7 +30,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
.BDDfy();
}
[Fact]
public void can_match_down_stream_url_with_nothing_then_placeholder_no_value_is_blank()
{
@ -264,4 +263,4 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
_result = _finder.Find(_downstreamUrlPath, _downstreamPathTemplate);
}
}
}
}

View File

@ -29,7 +29,6 @@ namespace Ocelot.UnitTests.Errors
private DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;
public ExceptionHandlerMiddlewareTests()
{
_provider = new Mock<IOcelotConfigurationProvider>();
@ -135,7 +134,7 @@ namespace Ocelot.UnitTests.Errors
private void GivenTheConfigThrows()
{
var ex = new Exception("outer", new Exception("inner"));
var ex = new Exception("outer", new Exception("inner"));
_provider
.Setup(x => x.Get()).ThrowsAsync(ex);
}
@ -174,7 +173,6 @@ namespace Ocelot.UnitTests.Errors
.Setup(x => x.Get()).ReturnsAsync(response);
}
private void GivenAnExceptionWillNotBeThrownDownstream()
{
_shouldThrowAnException = false;
@ -192,7 +190,6 @@ namespace Ocelot.UnitTests.Errors
private void ThenTheResponseIsError()
{
_downstreamContext.HttpContext.Response.StatusCode.ShouldBe(500);
}

View File

@ -130,7 +130,6 @@ namespace Ocelot.UnitTests.Headers
private void ThenTheResultIsError()
{
_result.IsError.ShouldBe(true);
}

View File

@ -80,7 +80,6 @@ namespace Ocelot.UnitTests.Headers
_downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues;
_downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0];
}
private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly()

View File

@ -22,6 +22,7 @@ namespace Ocelot.UnitTests.Headers
{
_replacer = new HttpResponseHeaderReplacer();
}
[Fact]
public void should_replace_headers()
{
@ -97,7 +98,6 @@ namespace Ocelot.UnitTests.Headers
.BDDfy();
}
[Fact]
public void should_replace_downstream_base_url_with_ocelot_base_url_and_path()
{
@ -232,4 +232,4 @@ namespace Ocelot.UnitTests.Headers
}
}
}
}
}

View File

@ -21,13 +21,14 @@ namespace Ocelot.UnitTests.Infrastructure
_httpDataRepository = new HttpDataRepository(_httpContextAccessor);
}
//TODO - Additional tests -> Type mistmatch aka Add string, request int
//TODO - Additional tests -> HttpContent null. This should never happen
/*
TODO - Additional tests -> Type mistmatch aka Add string, request int
TODO - Additional tests -> HttpContent null. This should never happen
*/
[Fact]
public void get_returns_correct_key_from_http_context()
{
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
.When(x => x.GetIsCalledWithKey<string>("key"))
.Then(x => x.ThenTheResultIsAnOkResponse<string>("string"))
@ -83,6 +84,5 @@ namespace Ocelot.UnitTests.Infrastructure
_result.ShouldBeOfType<OkResponse<T>>();
((OkResponse<T>)_result).Data.ShouldBe(resultValue);
}
}
}

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Infrastructure
.BDDfy();
}
[Fact]
public void should_return_ok_if_null_allowed_scopes()
{
@ -121,4 +120,4 @@ namespace Ocelot.UnitTests.Infrastructure
{
}
}
}
}

View File

@ -91,7 +91,6 @@ namespace Ocelot.UnitTests.LoadBalancer
hostAndPortTwo.Data.DownstreamHost.ShouldBe("127.0.0.2");
_leastConnection.Release(hostAndPortOne.Data);
_leastConnection.Release(hostAndPortTwo.Data);
}
private async Task LeaseDelayAndRelease()

View File

@ -17,9 +17,7 @@ namespace Ocelot.UnitTests.LoadBalancer
private DownstreamReRoute _reRoute;
private ILoadBalancer _loadBalancer;
private readonly LoadBalancerHouse _loadBalancerHouse;
private Response _addResult;
private Response<ILoadBalancer> _getResult;
private string _key;
private readonly Mock<ILoadBalancerFactory> _factory;
private ServiceProviderConfiguration _serviceProviderConfig;
@ -116,7 +114,6 @@ namespace Ocelot.UnitTests.LoadBalancer
_factory.Verify(x => x.Get(_reRoute, _serviceProviderConfig), Times.Once);
}
private void GivenThereIsALoadBalancer(DownstreamReRoute reRoute, ILoadBalancer loadBalancer)
{
_reRoute = reRoute;

View File

@ -4,15 +4,10 @@ namespace Ocelot.UnitTests.LoadBalancer
{
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Provider;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Errors;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.LoadBalancer.Middleware;
@ -28,7 +23,6 @@ namespace Ocelot.UnitTests.LoadBalancer
private readonly Mock<ILoadBalancerHouse> _loadBalancerHouse;
private readonly Mock<ILoadBalancer> _loadBalancer;
private ServiceHostAndPort _hostAndPort;
private OkResponse<DownstreamRoute> _downstreamRoute;
private ErrorResponse<ILoadBalancer> _getLoadBalancerHouseError;
private ErrorResponse<ServiceHostAndPort> _getHostAndPortError;
private HttpRequestMessage _downstreamRequest;
@ -188,7 +182,6 @@ namespace Ocelot.UnitTests.LoadBalancer
{
_downstreamContext.IsError.ShouldBeTrue();
_downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
}
private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)

View File

@ -58,7 +58,6 @@ namespace Ocelot.UnitTests.Middleware
private void WhenIMultiplex()
{
_multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult();
}
private void ThePipelineIsCalled(int expected)

View File

@ -1,6 +1,5 @@
namespace Ocelot.UnitTests.Middleware
{
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
@ -17,9 +16,7 @@
public class OcelotPiplineBuilderTests
{
private readonly IServiceCollection _services;
private IServiceProvider _serviceProvider;
private readonly IConfiguration _configRoot;
private IOcelotBuilder _ocelotBuilder;
private DownstreamContext _downstreamContext;
private int _counter;

View File

@ -42,7 +42,6 @@ namespace Ocelot.UnitTests.Middleware
.WithDownstreamReRoutes(downstreamReRoutes)
.Build();
var billDownstreamContext = new DownstreamContext(new DefaultHttpContext())
{
DownstreamResponse =

View File

@ -12,6 +12,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -37,6 +38,9 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />

View File

@ -19,7 +19,6 @@ namespace Ocelot.UnitTests.RateLimit
using Microsoft.Extensions.Caching.Memory;
using System.IO;
public class ClientRateLimitMiddlewareTests
{
private int _responseStatusCode;

View File

@ -36,7 +36,6 @@ namespace Ocelot.UnitTests.Request
public DownstreamRequestInitialiserMiddlewareTests()
{
_httpContext = new Mock<HttpContext>();
_httpRequest = new Mock<HttpRequest>();
_requestMapper = new Mock<IRequestMapper>();

View File

@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.RequestId
{
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Infrastructure.RequestData;
using System;
using System.Collections.Generic;
@ -24,7 +23,6 @@ namespace Ocelot.UnitTests.RequestId
public class ReRouteRequestIdMiddlewareTests
{
private readonly HttpRequestMessage _downstreamRequest;
private Response<DownstreamRoute> _downstreamRoute;
private string _value;
private string _key;
private Mock<IOcelotLoggerFactory> _loggerFactory;
@ -165,7 +163,6 @@ namespace Ocelot.UnitTests.RequestId
_repo.Verify(x => x.Update<string>("RequestId", _value), Times.Once);
}
private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute)
{
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;

View File

@ -41,7 +41,6 @@ namespace Ocelot.UnitTests.Requester
.Returns(qosProvider);
}
[Fact]
public void should_all_from_all_routes_provider_and_qos()
{

View File

@ -9,13 +9,13 @@ namespace Ocelot.UnitTests.Requester
{
public FakeDelegatingHandler()
{
}
public FakeDelegatingHandler(int order)
{
Order = order;
}
public int Order {get;private set;}
public DateTime TimeCalled {get;private set;}
@ -25,4 +25,4 @@ namespace Ocelot.UnitTests.Requester
return new HttpResponseMessage();
}
}
}
}

View File

@ -17,7 +17,6 @@ namespace Ocelot.UnitTests.Requester
private readonly HttpClientBuilder _builder;
private readonly Mock<IDelegatingHandlerHandlerHouse> _house;
private readonly Mock<IDelegatingHandlerHandlerProvider> _provider;
private IHttpClientBuilder _builderResult;
private IHttpClient _httpClient;
private HttpResponseMessage _response;
private DownstreamReRoute _request;

View File

@ -13,7 +13,6 @@ namespace Ocelot.UnitTests.Requester
{
private IQoSProvider _qoSProvider;
private readonly QosProviderHouse _qosProviderHouse;
private Response _addResult;
private Response<IQoSProvider> _getResult;
private DownstreamReRoute _reRoute;
private readonly Mock<IQoSProviderFactory> _factory;
@ -111,7 +110,6 @@ namespace Ocelot.UnitTests.Requester
_getResult.Data.ShouldBe(_qoSProvider);
}
private void GivenThereIsAQoSProvider(DownstreamReRoute reRoute, IQoSProvider qoSProvider)
{
_reRoute = reRoute;

View File

@ -42,10 +42,9 @@ namespace Ocelot.UnitTests.Responder
[InlineData(OcelotErrorCode.RequestTimedOutError)]
public void should_return_service_unavailable(OcelotErrorCode errorCode)
{
ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable);
ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.ServiceUnavailable);
}
[Theory]
[InlineData(OcelotErrorCode.CannotAddDataError)]
[InlineData(OcelotErrorCode.CannotFindDataError)]

View File

@ -4,7 +4,6 @@ using Ocelot.Middleware;
namespace Ocelot.UnitTests.Responder
{
using Microsoft.AspNetCore.Http;
using Ocelot.DownstreamRouteFinder.Middleware;
using System.Net.Http;
using Moq;
using Ocelot.DownstreamRouteFinder.Finder;
@ -12,7 +11,6 @@ namespace Ocelot.UnitTests.Responder
using Ocelot.Logging;
using Ocelot.Responder;
using Ocelot.Responder.Middleware;
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
@ -20,14 +18,12 @@ namespace Ocelot.UnitTests.Responder
{
private readonly Mock<IHttpResponder> _responder;
private readonly Mock<IErrorsToHttpStatusCodeMapper> _codeMapper;
private OkResponse<HttpResponseMessage> _response;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private readonly ResponderMiddleware _middleware;
private readonly DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;
public ResponderMiddlewareTests()
{
_responder = new Mock<IHttpResponder>();

View File

@ -131,8 +131,7 @@ namespace Ocelot.UnitTests.ServiceDiscovery
else
{
_registeredServices[serviceNameAndAddress.Name] = new List<Service>(){ serviceNameAndAddress };
}
}
}
}
}

View File

@ -0,0 +1,10 @@
namespace Ocelot.UnitTests
{
public class Wait
{
public static Waiter WaitFor(int milliSeconds)
{
return new Waiter(milliSeconds);
}
}
}

View File

@ -3,14 +3,6 @@ using System.Diagnostics;
namespace Ocelot.UnitTests
{
public class Wait
{
public static Waiter WaitFor(int milliSeconds)
{
return new Waiter(milliSeconds);
}
}
public class Waiter
{
private readonly int _milliSeconds;
@ -52,4 +44,4 @@ namespace Ocelot.UnitTests
return passed;
}
}
}
}