added benchmarks back in, renamed data repository and a few other things

This commit is contained in:
TomPallister
2016-10-24 19:32:52 +01:00
parent d50f06fc3e
commit 9c771bf9e0
29 changed files with 153 additions and 125 deletions

View File

@ -11,8 +11,8 @@ using Ocelot.Authentication.Middleware;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -20,7 +20,7 @@ namespace Ocelot.UnitTests.Authentication
{
public class AuthenticationMiddlewareTests : IDisposable
{
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly Mock<IAuthenticationHandlerFactory> _authFactory;
private readonly string _url;
private readonly TestServer _server;
@ -31,7 +31,7 @@ namespace Ocelot.UnitTests.Authentication
public AuthenticationMiddlewareTests()
{
_url = "http://localhost:51879";
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
_authFactory = new Mock<IAuthenticationHandlerFactory>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -11,8 +11,8 @@ using Ocelot.Authorisation;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -22,7 +22,7 @@ namespace Ocelot.UnitTests.Authorization
public class AuthorisationMiddlewareTests : IDisposable
{
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly Mock<IAuthoriser> _authService;
private readonly string _url;
private readonly TestServer _server;
@ -33,7 +33,7 @@ namespace Ocelot.UnitTests.Authorization
public AuthorisationMiddlewareTests()
{
_url = "http://localhost:51879";
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
_authService = new Mock<IAuthoriser>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -1,4 +1,6 @@
namespace Ocelot.UnitTests.ClaimsBuilder
using Ocelot.Infrastructure.RequestData;
namespace Ocelot.UnitTests.ClaimsBuilder
{
using System;
using System.Collections.Generic;
@ -16,13 +18,12 @@
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Responses;
using ScopedData;
using TestStack.BDDfy;
using Xunit;
public class ClaimsBuilderMiddlewareTests : IDisposable
{
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly Mock<IAddClaimsToRequest> _addHeaders;
private readonly string _url;
private readonly TestServer _server;
@ -33,7 +34,7 @@
public ClaimsBuilderMiddlewareTests()
{
_url = "http://localhost:51879";
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
_addHeaders = new Mock<IAddClaimsToRequest>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -11,8 +11,8 @@ using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -21,7 +21,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
public class DownstreamRouteFinderMiddlewareTests : IDisposable
{
private readonly Mock<IDownstreamRouteFinder> _downstreamRouteFinder;
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly string _url;
private readonly TestServer _server;
private readonly HttpClient _client;
@ -32,7 +32,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
{
_url = "http://localhost:51879";
_downstreamRouteFinder = new Mock<IDownstreamRouteFinder>();
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -11,8 +11,8 @@ using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.DownstreamUrlCreator.Middleware;
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -21,7 +21,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
public class DownstreamUrlCreatorMiddlewareTests : IDisposable
{
private readonly Mock<IDownstreamUrlTemplateVariableReplacer> _downstreamUrlTemplateVariableReplacer;
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly string _url;
private readonly TestServer _server;
private readonly HttpClient _client;
@ -33,7 +33,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
{
_url = "http://localhost:51879";
_downstreamUrlTemplateVariableReplacer = new Mock<IDownstreamUrlTemplateVariableReplacer>();
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -13,8 +13,8 @@ using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.HeaderBuilder;
using Ocelot.HeaderBuilder.Middleware;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -22,7 +22,7 @@ namespace Ocelot.UnitTests.HeaderBuilder
{
public class HttpRequestHeadersBuilderMiddlewareTests : IDisposable
{
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly Mock<IAddHeadersToRequest> _addHeaders;
private readonly string _url;
private readonly TestServer _server;
@ -33,7 +33,7 @@ namespace Ocelot.UnitTests.HeaderBuilder
public HttpRequestHeadersBuilderMiddlewareTests()
{
_url = "http://localhost:51879";
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
_addHeaders = new Mock<IAddHeadersToRequest>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responses;
using Ocelot.ScopedData;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
@ -9,7 +9,7 @@ namespace Ocelot.UnitTests.Repository
{
public class ScopedRequestDataRepositoryTests
{
private IScopedRequestDataRepository _scopedRequestDataRepository;
private IRequestScopedDataRepository _requestScopedDataRepository;
private IHttpContextAccessor _httpContextAccesor;
private string _key;
private object _toAdd;
@ -19,7 +19,7 @@ namespace Ocelot.UnitTests.Repository
{
_httpContextAccesor = new HttpContextAccessor();
_httpContextAccesor.HttpContext = new DefaultHttpContext();
_scopedRequestDataRepository = new ScopedRequestDataRepository(_httpContextAccesor);
_requestScopedDataRepository = new HttpDataRepository(_httpContextAccesor);
}
[Fact]
@ -48,7 +48,7 @@ namespace Ocelot.UnitTests.Repository
private void WhenIGetTheItem()
{
_result = _scopedRequestDataRepository.Get<int[]>(_key);
_result = _requestScopedDataRepository.Get<int[]>(_key);
}
private void GivenThereIsAnItemInTheContext(string key)
@ -66,7 +66,7 @@ namespace Ocelot.UnitTests.Repository
private void WhenIAddTheItem()
{
_scopedRequestDataRepository.Add(_key, _toAdd);
_requestScopedDataRepository.Add(_key, _toAdd);
}
private void ThenTheItemIsAdded()

View File

@ -7,11 +7,11 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.RequestBuilder;
using Ocelot.RequestBuilder.Builder;
using Ocelot.RequestBuilder.Middleware;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -20,7 +20,7 @@ namespace Ocelot.UnitTests.RequestBuilder
public class HttpRequestBuilderMiddlewareTests : IDisposable
{
private readonly Mock<IRequestBuilder> _requestBuilder;
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly string _url;
private readonly TestServer _server;
private readonly HttpClient _client;
@ -32,7 +32,7 @@ namespace Ocelot.UnitTests.RequestBuilder
{
_url = "http://localhost:51879";
_requestBuilder = new Mock<IRequestBuilder>();
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -6,11 +6,11 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.RequestBuilder;
using Ocelot.Requester;
using Ocelot.Requester.Middleware;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -19,7 +19,7 @@ namespace Ocelot.UnitTests.Requester
public class HttpRequesterMiddlewareTests : IDisposable
{
private readonly Mock<IHttpRequester> _requester;
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly string _url;
private readonly TestServer _server;
private readonly HttpClient _client;
@ -31,7 +31,7 @@ namespace Ocelot.UnitTests.Requester
{
_url = "http://localhost:51879";
_requester = new Mock<IHttpRequester>();
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
var builder = new WebHostBuilder()
.ConfigureServices(x =>

View File

@ -6,10 +6,10 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Responder;
using Ocelot.Responder.Middleware;
using Ocelot.Responses;
using Ocelot.ScopedData;
using TestStack.BDDfy;
using Xunit;
@ -18,7 +18,7 @@ namespace Ocelot.UnitTests.Responder
public class HttpResponderMiddlewareTests : IDisposable
{
private readonly Mock<IHttpResponder> _responder;
private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IRequestScopedDataRepository> _scopedRepository;
private readonly Mock<IErrorsToHttpStatusCodeMapper> _codeMapper;
private readonly string _url;
private readonly TestServer _server;
@ -30,7 +30,7 @@ namespace Ocelot.UnitTests.Responder
{
_url = "http://localhost:51879";
_responder = new Mock<IHttpResponder>();
_scopedRepository = new Mock<IScopedRequestDataRepository>();
_scopedRepository = new Mock<IRequestScopedDataRepository>();
_codeMapper = new Mock<IErrorsToHttpStatusCodeMapper>();
var builder = new WebHostBuilder()