mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
Fix various violations
SA1216, CS0105, CS0169, CS0414, CS0649
This commit is contained in:
parent
a64e263a26
commit
50980fda93
@ -89,7 +89,8 @@ namespace Ocelot.Raft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response<T> Request<T>(T command) where T : ICommand
|
public Response<T> Request<T>(T command)
|
||||||
|
where T : ICommand
|
||||||
{
|
{
|
||||||
if(_token == null)
|
if(_token == null)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
public class AggregateTests : IDisposable
|
public class AggregateTests : IDisposable
|
||||||
{
|
{
|
||||||
private IWebHost _serviceOneBuilder;
|
private IWebHost _serviceOneBuilder;
|
||||||
private IWebHost _serviceTwoBuilder;
|
|
||||||
private readonly Steps _steps;
|
private readonly Steps _steps;
|
||||||
private string _downstreamPathOne;
|
private string _downstreamPathOne;
|
||||||
private string _downstreamPathTwo;
|
private string _downstreamPathTwo;
|
||||||
@ -364,7 +363,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_serviceOneBuilder?.Dispose();
|
_serviceOneBuilder?.Dispose();
|
||||||
_serviceTwoBuilder?.Dispose();
|
|
||||||
_steps.Dispose();
|
_steps.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using TestStack.BDDfy;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Ocelot.AcceptanceTests
|
namespace Ocelot.AcceptanceTests
|
||||||
{
|
{
|
||||||
public class CannotStartOcelotTests : IDisposable
|
public class CannotStartOcelotTests : IDisposable
|
||||||
{
|
{
|
||||||
private IWebHost _builder;
|
|
||||||
private readonly Steps _steps;
|
private readonly Steps _steps;
|
||||||
private string _downstreamPath;
|
|
||||||
|
|
||||||
public CannotStartOcelotTests()
|
public CannotStartOcelotTests()
|
||||||
{
|
{
|
||||||
@ -50,7 +46,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_builder?.Dispose();
|
|
||||||
_steps.Dispose();
|
_steps.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -19,15 +17,11 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Configuration.Repository;
|
|
||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
using Ocelot.ServiceDiscovery;
|
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
|
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
|
||||||
using Ocelot.AcceptanceTests.Caching;
|
using Ocelot.AcceptanceTests.Caching;
|
||||||
using Butterfly.Client.AspNetCore;
|
|
||||||
using Butterfly.Client.Tracing;
|
|
||||||
|
|
||||||
namespace Ocelot.AcceptanceTests
|
namespace Ocelot.AcceptanceTests
|
||||||
{
|
{
|
||||||
@ -42,11 +36,9 @@ namespace Ocelot.AcceptanceTests
|
|||||||
public string RequestIdKey = "OcRequestId";
|
public string RequestIdKey = "OcRequestId";
|
||||||
private readonly Random _random;
|
private readonly Random _random;
|
||||||
private IWebHostBuilder _webHostBuilder;
|
private IWebHostBuilder _webHostBuilder;
|
||||||
private readonly string _baseUrl;
|
|
||||||
|
|
||||||
public Steps()
|
public Steps()
|
||||||
{
|
{
|
||||||
_baseUrl = "http://localhost:5000";
|
|
||||||
_random = new Random();
|
_random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,24 +6,17 @@ namespace Ocelot.UnitTests.Authentication
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Authentication.Middleware;
|
using Ocelot.Authentication.Middleware;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
public class AuthenticationMiddlewareTests
|
public class AuthenticationMiddlewareTests
|
||||||
{
|
{
|
||||||
private OkResponse<DownstreamRoute> _downstreamRoute;
|
|
||||||
private AuthenticationMiddleware _middleware;
|
private AuthenticationMiddleware _middleware;
|
||||||
private Mock<IOcelotLoggerFactory> _factory;
|
private Mock<IOcelotLoggerFactory> _factory;
|
||||||
private Mock<IOcelotLogger> _logger;
|
private Mock<IOcelotLogger> _logger;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Ocelot.Errors;
|
using Ocelot.Errors;
|
||||||
using Ocelot.Infrastructure.RequestData;
|
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
namespace Ocelot.UnitTests.Cache
|
namespace Ocelot.UnitTests.Cache
|
||||||
@ -11,26 +10,19 @@ namespace Ocelot.UnitTests.Cache
|
|||||||
using Shouldly;
|
using Shouldly;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Cache;
|
using Ocelot.Cache;
|
||||||
using Ocelot.Cache.Middleware;
|
using Ocelot.Cache.Middleware;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
public class OutputCacheMiddlewareRealCacheTests
|
public class OutputCacheMiddlewareRealCacheTests
|
||||||
{
|
{
|
||||||
private IOcelotCache<CachedResponse> _cacheManager;
|
private IOcelotCache<CachedResponse> _cacheManager;
|
||||||
private CachedResponse _response;
|
|
||||||
private OutputCacheMiddleware _middleware;
|
private OutputCacheMiddleware _middleware;
|
||||||
private DownstreamContext _downstreamContext;
|
private DownstreamContext _downstreamContext;
|
||||||
private OcelotRequestDelegate _next;
|
private OcelotRequestDelegate _next;
|
||||||
|
@ -15,12 +15,10 @@ namespace Ocelot.UnitTests.Claims
|
|||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
|
|
||||||
public class ClaimsBuilderMiddlewareTests
|
public class ClaimsBuilderMiddlewareTests
|
||||||
{
|
{
|
||||||
private readonly Mock<IAddClaimsToRequest> _addHeaders;
|
private readonly Mock<IAddClaimsToRequest> _addHeaders;
|
||||||
private Response<DownstreamRoute> _downstreamRoute;
|
|
||||||
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
||||||
private Mock<IOcelotLogger> _logger;
|
private Mock<IOcelotLogger> _logger;
|
||||||
private readonly ClaimsBuilderMiddleware _middleware;
|
private readonly ClaimsBuilderMiddleware _middleware;
|
||||||
|
@ -83,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
_setter.Verify(x => x.Set(fileConfig), Times.Once);
|
_setter.Verify(x => x.Set(fileConfig), Times.Once);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ using Ocelot.DependencyInjection;
|
|||||||
using Ocelot.Requester;
|
using Ocelot.Requester;
|
||||||
using Ocelot.UnitTests.Requester;
|
using Ocelot.UnitTests.Requester;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using System;
|
|
||||||
using IdentityServer4.AccessTokenValidation;
|
using IdentityServer4.AccessTokenValidation;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -17,9 +17,7 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
private DownstreamReRoute _reRoute;
|
private DownstreamReRoute _reRoute;
|
||||||
private ILoadBalancer _loadBalancer;
|
private ILoadBalancer _loadBalancer;
|
||||||
private readonly LoadBalancerHouse _loadBalancerHouse;
|
private readonly LoadBalancerHouse _loadBalancerHouse;
|
||||||
private Response _addResult;
|
|
||||||
private Response<ILoadBalancer> _getResult;
|
private Response<ILoadBalancer> _getResult;
|
||||||
private string _key;
|
|
||||||
private readonly Mock<ILoadBalancerFactory> _factory;
|
private readonly Mock<ILoadBalancerFactory> _factory;
|
||||||
private ServiceProviderConfiguration _serviceProviderConfig;
|
private ServiceProviderConfiguration _serviceProviderConfig;
|
||||||
|
|
||||||
|
@ -4,15 +4,10 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.Configuration.Provider;
|
|
||||||
using Ocelot.DownstreamRouteFinder;
|
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.Errors;
|
using Ocelot.Errors;
|
||||||
using Ocelot.LoadBalancer.LoadBalancers;
|
using Ocelot.LoadBalancer.LoadBalancers;
|
||||||
using Ocelot.LoadBalancer.Middleware;
|
using Ocelot.LoadBalancer.Middleware;
|
||||||
@ -28,7 +23,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
private readonly Mock<ILoadBalancerHouse> _loadBalancerHouse;
|
private readonly Mock<ILoadBalancerHouse> _loadBalancerHouse;
|
||||||
private readonly Mock<ILoadBalancer> _loadBalancer;
|
private readonly Mock<ILoadBalancer> _loadBalancer;
|
||||||
private ServiceHostAndPort _hostAndPort;
|
private ServiceHostAndPort _hostAndPort;
|
||||||
private OkResponse<DownstreamRoute> _downstreamRoute;
|
|
||||||
private ErrorResponse<ILoadBalancer> _getLoadBalancerHouseError;
|
private ErrorResponse<ILoadBalancer> _getLoadBalancerHouseError;
|
||||||
private ErrorResponse<ServiceHostAndPort> _getHostAndPortError;
|
private ErrorResponse<ServiceHostAndPort> _getHostAndPortError;
|
||||||
private HttpRequestMessage _downstreamRequest;
|
private HttpRequestMessage _downstreamRequest;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
namespace Ocelot.UnitTests.Middleware
|
namespace Ocelot.UnitTests.Middleware
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Internal;
|
using Microsoft.AspNetCore.Hosting.Internal;
|
||||||
@ -17,9 +16,7 @@
|
|||||||
public class OcelotPiplineBuilderTests
|
public class OcelotPiplineBuilderTests
|
||||||
{
|
{
|
||||||
private readonly IServiceCollection _services;
|
private readonly IServiceCollection _services;
|
||||||
private IServiceProvider _serviceProvider;
|
|
||||||
private readonly IConfiguration _configRoot;
|
private readonly IConfiguration _configRoot;
|
||||||
private IOcelotBuilder _ocelotBuilder;
|
|
||||||
private DownstreamContext _downstreamContext;
|
private DownstreamContext _downstreamContext;
|
||||||
private int _counter;
|
private int _counter;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.RequestId
|
|||||||
{
|
{
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.Infrastructure.RequestData;
|
using Ocelot.Infrastructure.RequestData;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -24,7 +23,6 @@ namespace Ocelot.UnitTests.RequestId
|
|||||||
public class ReRouteRequestIdMiddlewareTests
|
public class ReRouteRequestIdMiddlewareTests
|
||||||
{
|
{
|
||||||
private readonly HttpRequestMessage _downstreamRequest;
|
private readonly HttpRequestMessage _downstreamRequest;
|
||||||
private Response<DownstreamRoute> _downstreamRoute;
|
|
||||||
private string _value;
|
private string _value;
|
||||||
private string _key;
|
private string _key;
|
||||||
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
||||||
|
@ -17,7 +17,6 @@ namespace Ocelot.UnitTests.Requester
|
|||||||
private readonly HttpClientBuilder _builder;
|
private readonly HttpClientBuilder _builder;
|
||||||
private readonly Mock<IDelegatingHandlerHandlerHouse> _house;
|
private readonly Mock<IDelegatingHandlerHandlerHouse> _house;
|
||||||
private readonly Mock<IDelegatingHandlerHandlerProvider> _provider;
|
private readonly Mock<IDelegatingHandlerHandlerProvider> _provider;
|
||||||
private IHttpClientBuilder _builderResult;
|
|
||||||
private IHttpClient _httpClient;
|
private IHttpClient _httpClient;
|
||||||
private HttpResponseMessage _response;
|
private HttpResponseMessage _response;
|
||||||
private DownstreamReRoute _request;
|
private DownstreamReRoute _request;
|
||||||
|
@ -13,7 +13,6 @@ namespace Ocelot.UnitTests.Requester
|
|||||||
{
|
{
|
||||||
private IQoSProvider _qoSProvider;
|
private IQoSProvider _qoSProvider;
|
||||||
private readonly QosProviderHouse _qosProviderHouse;
|
private readonly QosProviderHouse _qosProviderHouse;
|
||||||
private Response _addResult;
|
|
||||||
private Response<IQoSProvider> _getResult;
|
private Response<IQoSProvider> _getResult;
|
||||||
private DownstreamReRoute _reRoute;
|
private DownstreamReRoute _reRoute;
|
||||||
private readonly Mock<IQoSProviderFactory> _factory;
|
private readonly Mock<IQoSProviderFactory> _factory;
|
||||||
|
@ -42,7 +42,7 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
[InlineData(OcelotErrorCode.RequestTimedOutError)]
|
[InlineData(OcelotErrorCode.RequestTimedOutError)]
|
||||||
public void should_return_service_unavailable(OcelotErrorCode errorCode)
|
public void should_return_service_unavailable(OcelotErrorCode errorCode)
|
||||||
{
|
{
|
||||||
ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable);
|
ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.ServiceUnavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
@ -4,7 +4,6 @@ using Ocelot.Middleware;
|
|||||||
namespace Ocelot.UnitTests.Responder
|
namespace Ocelot.UnitTests.Responder
|
||||||
{
|
{
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.DownstreamRouteFinder.Finder;
|
using Ocelot.DownstreamRouteFinder.Finder;
|
||||||
@ -12,7 +11,6 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responder;
|
using Ocelot.Responder;
|
||||||
using Ocelot.Responder.Middleware;
|
using Ocelot.Responder.Middleware;
|
||||||
using Ocelot.Responses;
|
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -20,7 +18,6 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
{
|
{
|
||||||
private readonly Mock<IHttpResponder> _responder;
|
private readonly Mock<IHttpResponder> _responder;
|
||||||
private readonly Mock<IErrorsToHttpStatusCodeMapper> _codeMapper;
|
private readonly Mock<IErrorsToHttpStatusCodeMapper> _codeMapper;
|
||||||
private OkResponse<HttpResponseMessage> _response;
|
|
||||||
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
||||||
private Mock<IOcelotLogger> _logger;
|
private Mock<IOcelotLogger> _logger;
|
||||||
private readonly ResponderMiddleware _middleware;
|
private readonly ResponderMiddleware _middleware;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user