mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:30:49 +08:00 
			
		
		
		
	Fix various violations
SA1216, CS0105, CS0169, CS0414, CS0649
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -83,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
			
		||||
                    _setter.Verify(x => x.Set(fileConfig), Times.Once);
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
                catch(Exception ex)
 | 
			
		||||
                catch(Exception)
 | 
			
		||||
                {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ 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]
 | 
			
		||||
 
 | 
			
		||||
@@ -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,7 +18,6 @@ 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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user