mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:30:49 +08:00 
			
		
		
		
	Merge pull request #261 from binarymash/feature/ReduceBuildWarnings
Feature/reduce build warnings
This commit is contained in:
		@@ -6,6 +6,7 @@ namespace Ocelot.UnitTests.Authentication
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Text;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Authentication.Middleware;
 | 
			
		||||
@@ -44,10 +45,11 @@ namespace Ocelot.UnitTests.Authentication
 | 
			
		||||
 | 
			
		||||
        private void WhenICallTheMiddleware()
 | 
			
		||||
        {
 | 
			
		||||
            _next = async (context) => {
 | 
			
		||||
            _next = (context) => {
 | 
			
		||||
                byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
 | 
			
		||||
                MemoryStream stream = new MemoryStream(byteArray);
 | 
			
		||||
                var stream = new MemoryStream(byteArray);
 | 
			
		||||
                context.HttpContext.Response.Body = stream;
 | 
			
		||||
                return Task.CompletedTask;
 | 
			
		||||
            };
 | 
			
		||||
            _middleware = new AuthenticationMiddleware(_next, _factory.Object);
 | 
			
		||||
            _middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
 | 
			
		||||
@@ -55,10 +57,11 @@ namespace Ocelot.UnitTests.Authentication
 | 
			
		||||
 | 
			
		||||
        private void GivenTheTestServerPipelineIsConfigured()
 | 
			
		||||
        {
 | 
			
		||||
            _next = async (context) => {
 | 
			
		||||
            _next = (context) => {
 | 
			
		||||
                byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
 | 
			
		||||
                MemoryStream stream = new MemoryStream(byteArray);
 | 
			
		||||
                var stream = new MemoryStream(byteArray);
 | 
			
		||||
                context.HttpContext.Response.Body = stream;
 | 
			
		||||
                return Task.CompletedTask;
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,18 +4,17 @@ namespace Ocelot.UnitTests.Authorization
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Security.Claims;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Authorisation;
 | 
			
		||||
    using Ocelot.Authorisation.Middleware;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Responses;
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
 | 
			
		||||
    public class AuthorisationMiddlewareTests
 | 
			
		||||
@@ -36,9 +35,7 @@ namespace Ocelot.UnitTests.Authorization
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new AuthorisationMiddleware(_next, _authService.Object, _authScopesService.Object, _loggerFactory.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Cache;
 | 
			
		||||
    using Ocelot.Cache.Middleware;
 | 
			
		||||
@@ -43,9 +44,7 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
            _cacheManager = new OcelotCacheManagerCache<CachedResponse>(cacheManagerOutputCache);
 | 
			
		||||
            _downstreamContext = new DownstreamContext(new DefaultHttpContext());
 | 
			
		||||
            _downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing..
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new OutputCacheMiddleware(_next, _loggerFactory.Object, _cacheManager, _regionCreator);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,19 +7,16 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    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.Middleware;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Responses;
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
@@ -42,10 +39,7 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<OutputCacheMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
namespace Ocelot.UnitTests.Claims
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Claims;
 | 
			
		||||
@@ -32,9 +33,7 @@ namespace Ocelot.UnitTests.Claims
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<ClaimsBuilderMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new ClaimsBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,8 @@ using Ocelot.Middleware.Multiplexer;
 | 
			
		||||
namespace Ocelot.UnitTests.DownstreamRouteFinder
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
@@ -42,9 +41,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<DownstreamRouteFinderMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _multiplexer = new Mock<IMultiplexer>();
 | 
			
		||||
            _middleware = new DownstreamRouteFinderMiddleware(_next, _loggerFactory.Object, _finder.Object, _provider.Object, _multiplexer.Object);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,23 +6,19 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
    using Ocelot.DownstreamUrlCreator;
 | 
			
		||||
    using Ocelot.DownstreamUrlCreator.Middleware;
 | 
			
		||||
    using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
 | 
			
		||||
    using Ocelot.Infrastructure.RequestData;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Responses;
 | 
			
		||||
    using Ocelot.Values;
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
 | 
			
		||||
    public class DownstreamUrlCreatorMiddlewareTests
 | 
			
		||||
@@ -43,9 +39,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<DownstreamUrlCreatorMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _downstreamUrlTemplateVariableReplacer = new Mock<IDownstreamPathPlaceholderReplacer>();
 | 
			
		||||
            _downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://my.url/abc/?q=123");
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
 
 | 
			
		||||
@@ -11,11 +11,12 @@ using Ocelot.Configuration.Builder;
 | 
			
		||||
using Ocelot.Headers;
 | 
			
		||||
using System.Net.Http;
 | 
			
		||||
using Ocelot.Authorisation.Middleware;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
using Ocelot.Middleware;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Headers
 | 
			
		||||
{
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class HttpHeadersTransformationMiddlewareTests
 | 
			
		||||
    {
 | 
			
		||||
        private Mock<IHttpContextRequestHeaderReplacer> _preReplacer;
 | 
			
		||||
@@ -34,9 +35,7 @@ namespace Ocelot.UnitTests.Headers
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new HttpHeadersTransformationMiddleware(_next, _loggerFactory.Object, _preReplacer.Object, _postReplacer.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,14 +4,12 @@ namespace Ocelot.UnitTests.Headers
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
    using Ocelot.Headers;
 | 
			
		||||
    using Ocelot.Headers.Middleware;
 | 
			
		||||
@@ -37,9 +35,7 @@ namespace Ocelot.UnitTests.Headers
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<HttpRequestHeadersBuilderMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new HttpRequestHeadersBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
 | 
			
		||||
            _downstreamContext.DownstreamRequest = new HttpRequestMessage();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,12 +19,13 @@ namespace Ocelot.UnitTests.LoadBalancer
 | 
			
		||||
        private readonly LoadBalancerHouse _loadBalancerHouse;
 | 
			
		||||
        private Response<ILoadBalancer> _getResult;
 | 
			
		||||
        private readonly Mock<ILoadBalancerFactory> _factory;
 | 
			
		||||
        private ServiceProviderConfiguration _serviceProviderConfig;
 | 
			
		||||
        private readonly ServiceProviderConfiguration _serviceProviderConfig;
 | 
			
		||||
 | 
			
		||||
        public LoadBalancerHouseTests()
 | 
			
		||||
        {
 | 
			
		||||
            _factory = new Mock<ILoadBalancerFactory>();
 | 
			
		||||
            _loadBalancerHouse = new LoadBalancerHouse(_factory.Object);
 | 
			
		||||
            _serviceProviderConfig = new ServiceProviderConfiguration("myType","myHost",123);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ namespace Ocelot.UnitTests.LoadBalancer
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
@@ -43,9 +44,7 @@ namespace Ocelot.UnitTests.LoadBalancer
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<LoadBalancingMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _downstreamContext.DownstreamRequest = _downstreamRequest;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ namespace Ocelot.UnitTests.Middleware
 | 
			
		||||
        {
 | 
			
		||||
            _aggregator = new Mock<IResponseAggregator>();
 | 
			
		||||
            _context = new DownstreamContext(new DefaultHttpContext());
 | 
			
		||||
            _pipeline = async context => { _count++; }; 
 | 
			
		||||
            _pipeline = context => Task.FromResult(_count++); 
 | 
			
		||||
            _multiplexer = new Multiplexer(_aggregator.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.QueryStrings
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
@@ -17,9 +16,8 @@ namespace Ocelot.UnitTests.QueryStrings
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
    using System.Security.Claims;
 | 
			
		||||
    using Microsoft.AspNetCore.Builder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class QueryStringBuilderMiddlewareTests
 | 
			
		||||
    {
 | 
			
		||||
@@ -36,9 +34,7 @@ namespace Ocelot.UnitTests.QueryStrings
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<QueryStringBuilderMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _addQueries = new Mock<IAddQueriesToRequest>();
 | 
			
		||||
            _downstreamContext.DownstreamRequest = new HttpRequestMessage();
 | 
			
		||||
            _middleware = new QueryStringBuilderMiddleware(_next, _loggerFactory.Object, _addQueries.Object);
 | 
			
		||||
 
 | 
			
		||||
@@ -15,9 +15,9 @@ namespace Ocelot.UnitTests.RateLimit
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Middleware;
 | 
			
		||||
    using Microsoft.Extensions.Caching.Memory;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class ClientRateLimitMiddlewareTests
 | 
			
		||||
    {
 | 
			
		||||
@@ -42,8 +42,7 @@ namespace Ocelot.UnitTests.RateLimit
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<ClientRateLimitMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
             _next = async (context) => {
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new ClientRateLimitMiddleware(_next, _loggerFactory.Object, _rateLimitCounterHandler);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ namespace Ocelot.UnitTests.RequestId
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Linq;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder;
 | 
			
		||||
@@ -40,8 +41,10 @@ namespace Ocelot.UnitTests.RequestId
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<ReRouteRequestIdMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
            _next = context =>
 | 
			
		||||
            {
 | 
			
		||||
                context.HttpContext.Response.Headers.Add("LSRequestId", context.HttpContext.TraceIdentifier);
 | 
			
		||||
                return Task.CompletedTask;
 | 
			
		||||
            };
 | 
			
		||||
            _middleware = new ReRouteRequestIdMiddleware(_next, _loggerFactory.Object, _repo.Object);
 | 
			
		||||
            _downstreamContext.DownstreamRequest = _downstreamRequest;
 | 
			
		||||
 
 | 
			
		||||
@@ -17,12 +17,13 @@ namespace Ocelot.UnitTests.Requester
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int Order {get;private set;}
 | 
			
		||||
 | 
			
		||||
        public DateTime TimeCalled {get;private set;}
 | 
			
		||||
 | 
			
		||||
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 | 
			
		||||
        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 | 
			
		||||
        {
 | 
			
		||||
            TimeCalled = DateTime.Now;
 | 
			
		||||
            return new HttpResponseMessage();
 | 
			
		||||
            return Task.FromResult(new HttpResponseMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ namespace Ocelot.UnitTests.Requester
 | 
			
		||||
    using TestStack.BDDfy;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
    public class HttpRequesterMiddlewareTests
 | 
			
		||||
    {
 | 
			
		||||
@@ -30,9 +31,7 @@ namespace Ocelot.UnitTests.Requester
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<HttpRequesterMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new HttpRequesterMiddleware(_next, _loggerFactory.Object, _requester.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ namespace Ocelot.UnitTests.Responder
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.AspNetCore.Http;
 | 
			
		||||
    using System.Net.Http;
 | 
			
		||||
    using System.Threading.Tasks;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.DownstreamRouteFinder.Finder;
 | 
			
		||||
    using Ocelot.Errors;
 | 
			
		||||
@@ -32,9 +33,7 @@ namespace Ocelot.UnitTests.Responder
 | 
			
		||||
            _loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _loggerFactory.Setup(x => x.CreateLogger<ResponderMiddleware>()).Returns(_logger.Object);
 | 
			
		||||
            _next = async context => {
 | 
			
		||||
                //do nothing
 | 
			
		||||
            };
 | 
			
		||||
            _next = context => Task.CompletedTask;
 | 
			
		||||
            _middleware = new ResponderMiddleware(_next, _responder.Object, _loggerFactory.Object, _codeMapper.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user