diff --git a/src/Ocelot/Configuration/Repository/FileConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/FileConfigurationRepository.cs index 29a0c36e..ff5e3876 100644 --- a/src/Ocelot/Configuration/Repository/FileConfigurationRepository.cs +++ b/src/Ocelot/Configuration/Repository/FileConfigurationRepository.cs @@ -18,7 +18,7 @@ namespace Ocelot.Configuration.Repository _configFilePath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(hostingEnvironment.EnvironmentName) ? string.Empty : ".")}{hostingEnvironment.EnvironmentName}.json"; } - public async Task> Get() + public Task> Get() { string jsonConfiguration; @@ -29,10 +29,10 @@ namespace Ocelot.Configuration.Repository var fileConfiguration = JsonConvert.DeserializeObject(jsonConfiguration); - return new OkResponse(fileConfiguration); + return Task.FromResult>(new OkResponse(fileConfiguration)); } - public async Task Set(FileConfiguration fileConfiguration) + public Task Set(FileConfiguration fileConfiguration) { string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration); @@ -45,8 +45,8 @@ namespace Ocelot.Configuration.Repository System.IO.File.WriteAllText(_configFilePath, jsonConfiguration); } - - return new OkResponse(); + + return Task.FromResult(new OkResponse()); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Configuration/Repository/InMemoryOcelotConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/InMemoryOcelotConfigurationRepository.cs index 99f6a51b..9ce50ba6 100644 --- a/src/Ocelot/Configuration/Repository/InMemoryOcelotConfigurationRepository.cs +++ b/src/Ocelot/Configuration/Repository/InMemoryOcelotConfigurationRepository.cs @@ -12,19 +12,19 @@ namespace Ocelot.Configuration.Repository private IOcelotConfiguration _ocelotConfiguration; - public async Task> Get() + public Task> Get() { - return new OkResponse(_ocelotConfiguration); + return Task.FromResult>(new OkResponse(_ocelotConfiguration)); } - public async Task AddOrReplace(IOcelotConfiguration ocelotConfiguration) + public Task AddOrReplace(IOcelotConfiguration ocelotConfiguration) { lock (LockObject) { _ocelotConfiguration = ocelotConfiguration; } - return new OkResponse(); + return Task.FromResult(new OkResponse()); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/ServiceDiscovery/ServiceFabricServiceDiscoveryProvider.cs b/src/Ocelot/ServiceDiscovery/ServiceFabricServiceDiscoveryProvider.cs index 28f9bb65..257298b7 100644 --- a/src/Ocelot/ServiceDiscovery/ServiceFabricServiceDiscoveryProvider.cs +++ b/src/Ocelot/ServiceDiscovery/ServiceFabricServiceDiscoveryProvider.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Ocelot.Values; @@ -14,16 +13,16 @@ namespace Ocelot.ServiceDiscovery _configuration = configuration; } - public async Task> Get() + public Task> Get() { - return new List + return Task.FromResult(new List { new Service(_configuration.ServiceName, new ServiceHostAndPort(_configuration.HostName, _configuration.Port), "doesnt matter with service fabric", "doesnt matter with service fabric", new List()) - }; + }); } } } diff --git a/test/Ocelot.AcceptanceTests/HeaderTests.cs b/test/Ocelot.AcceptanceTests/HeaderTests.cs index b5a2711e..0e0db202 100644 --- a/test/Ocelot.AcceptanceTests/HeaderTests.cs +++ b/test/Ocelot.AcceptanceTests/HeaderTests.cs @@ -221,13 +221,15 @@ namespace Ocelot.AcceptanceTests .Configure(app => { app.UsePathBase(basePath); - app.Run(async context => + app.Run(context => { context.Response.OnStarting(() => { context.Response.Headers.Add(headerKey, headerValue); context.Response.StatusCode = statusCode; return Task.CompletedTask; }); + + return Task.CompletedTask; }); }) .Build(); diff --git a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs index e5cb64ae..e287d5f4 100644 --- a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs @@ -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; }; } diff --git a/test/Ocelot.UnitTests/Authorization/AuthorisationMiddlewareTests.cs b/test/Ocelot.UnitTests/Authorization/AuthorisationMiddlewareTests.cs index 6f1d54f3..472c8643 100644 --- a/test/Ocelot.UnitTests/Authorization/AuthorisationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Authorization/AuthorisationMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new AuthorisationMiddleware(_next, _authService.Object, _authScopesService.Object, _loggerFactory.Object); } diff --git a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs index c0a76b2a..210b1cb5 100644 --- a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs +++ b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs @@ -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(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); } diff --git a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs index 31cc11a8..78911787 100644 --- a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; - + _next = context => Task.CompletedTask; _downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"); } diff --git a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs index f6bf052c..02e9d8fc 100644 --- a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new ClaimsBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object); } diff --git a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderMiddlewareTests.cs b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderMiddlewareTests.cs index a5c18c22..d3363b00 100644 --- a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _multiplexer = new Mock(); _middleware = new DownstreamRouteFinderMiddleware(_next, _loggerFactory.Object, _finder.Object, _provider.Object, _multiplexer.Object); } diff --git a/test/Ocelot.UnitTests/DownstreamUrlCreator/DownstreamUrlCreatorMiddlewareTests.cs b/test/Ocelot.UnitTests/DownstreamUrlCreator/DownstreamUrlCreatorMiddlewareTests.cs index 0d678a7b..c226f245 100644 --- a/test/Ocelot.UnitTests/DownstreamUrlCreator/DownstreamUrlCreatorMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/DownstreamUrlCreator/DownstreamUrlCreatorMiddlewareTests.cs @@ -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()).Returns(_logger.Object); _downstreamUrlTemplateVariableReplacer = new Mock(); _downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://my.url/abc/?q=123"); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; } [Fact] diff --git a/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs b/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs index 0a69bf89..3085a64d 100644 --- a/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs @@ -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 _preReplacer; @@ -34,9 +35,7 @@ namespace Ocelot.UnitTests.Headers _loggerFactory = new Mock(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new HttpHeadersTransformationMiddleware(_next, _loggerFactory.Object, _preReplacer.Object, _postReplacer.Object); } diff --git a/test/Ocelot.UnitTests/Headers/HttpRequestHeadersBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/Headers/HttpRequestHeadersBuilderMiddlewareTests.cs index 2f3a54d3..7f96b247 100644 --- a/test/Ocelot.UnitTests/Headers/HttpRequestHeadersBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Headers/HttpRequestHeadersBuilderMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new HttpRequestHeadersBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object); _downstreamContext.DownstreamRequest = new HttpRequestMessage(); } diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs index 242463a2..e03fe6e1 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _downstreamContext.DownstreamRequest = _downstreamRequest; } diff --git a/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs b/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs index adef00d5..1584c987 100644 --- a/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs +++ b/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs @@ -24,7 +24,7 @@ namespace Ocelot.UnitTests.Middleware { _aggregator = new Mock(); _context = new DownstreamContext(new DefaultHttpContext()); - _pipeline = async context => { _count++; }; + _pipeline = context => Task.FromResult(_count++); _multiplexer = new Multiplexer(_aggregator.Object); } diff --git a/test/Ocelot.UnitTests/QueryStrings/QueryStringBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/QueryStrings/QueryStringBuilderMiddlewareTests.cs index cfc0395d..163a0411 100644 --- a/test/Ocelot.UnitTests/QueryStrings/QueryStringBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/QueryStrings/QueryStringBuilderMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _addQueries = new Mock(); _downstreamContext.DownstreamRequest = new HttpRequestMessage(); _middleware = new QueryStringBuilderMiddleware(_next, _loggerFactory.Object, _addQueries.Object); diff --git a/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs b/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs index 57d2fdc8..819e38dd 100644 --- a/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async (context) => { - }; + _next = context => Task.CompletedTask; _middleware = new ClientRateLimitMiddleware(_next, _loggerFactory.Object, _rateLimitCounterHandler); } diff --git a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs index f6bf4eb7..e27fc50f 100644 --- a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).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; diff --git a/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs b/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs index a53487a3..0db47a8f 100644 --- a/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs +++ b/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs @@ -17,12 +17,13 @@ namespace Ocelot.UnitTests.Requester } public int Order {get;private set;} + public DateTime TimeCalled {get;private set;} - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { TimeCalled = DateTime.Now; - return new HttpResponseMessage(); + return Task.FromResult(new HttpResponseMessage()); } } } diff --git a/test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs b/test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs index 154beee8..f4facf5e 100644 --- a/test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new HttpRequesterMiddleware(_next, _loggerFactory.Object, _requester.Object); } diff --git a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs index 54b795a2..2e9ffcd6 100644 --- a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs @@ -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(); _logger = new Mock(); _loggerFactory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _next = async context => { - //do nothing - }; + _next = context => Task.CompletedTask; _middleware = new ResponderMiddleware(_next, _responder.Object, _loggerFactory.Object, _codeMapper.Object); }