Fixed Merge Conflicts

This commit is contained in:
Thiago Loureiro
2019-06-01 19:52:34 +08:00
545 changed files with 3522 additions and 3430 deletions

View File

@ -1,7 +1,5 @@
namespace Ocelot.UnitTests.Administration
{
using System;
using System.Collections.Generic;
using IdentityServer4.AccessTokenValidation;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
@ -10,6 +8,8 @@ namespace Ocelot.UnitTests.Administration
using Ocelot.Administration;
using Ocelot.DependencyInjection;
using Shouldly;
using System;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -33,7 +33,7 @@ namespace Ocelot.UnitTests.Administration
[Fact]
public void should_set_up_administration_with_identity_server_options()
{
Action<IdentityServerAuthenticationOptions> options = o => {};
Action<IdentityServerAuthenticationOptions> options = o => { };
this.Given(x => WhenISetUpOcelotServices())
.When(x => WhenISetUpAdministration(options))
@ -88,4 +88,3 @@ namespace Ocelot.UnitTests.Administration
}
}
}

View File

@ -4,20 +4,20 @@
namespace Ocelot.UnitTests.Authentication
{
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Authentication.Middleware;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Logging;
using Ocelot.Middleware;
using Shouldly;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Authentication.Middleware;
using Ocelot.Configuration.Builder;
using Ocelot.Logging;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using Ocelot.Configuration;
using Ocelot.Middleware;
public class AuthenticationMiddlewareTests
{
@ -62,7 +62,8 @@ namespace Ocelot.UnitTests.Authentication
private void WhenICallTheMiddleware()
{
_next = (context) => {
_next = (context) =>
{
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
var stream = new MemoryStream(byteArray);
context.HttpContext.Response.Body = stream;
@ -74,7 +75,8 @@ namespace Ocelot.UnitTests.Authentication
private void GivenTheTestServerPipelineIsConfigured()
{
_next = (context) => {
_next = (context) =>
{
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
var stream = new MemoryStream(byteArray);
context.HttpContext.Response.Body = stream;

View File

@ -2,21 +2,20 @@
namespace Ocelot.UnitTests.Authorization
{
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Authorisation;
using Ocelot.Authorisation.Middleware;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Values;
public class AuthorisationMiddlewareTests
{
@ -43,7 +42,7 @@ namespace Ocelot.UnitTests.Authorization
[Fact]
public void should_call_authorisation_service()
{
this.Given(x => x.GivenTheDownStreamRouteIs(new List<PlaceholderNameAndValue>(),
this.Given(x => x.GivenTheDownStreamRouteIs(new List<PlaceholderNameAndValue>(),
new DownstreamReRouteBuilder()
.WithUpstreamPathTemplate(new UpstreamPathTemplateBuilder().Build())
.WithIsAuthorised(true)
@ -86,4 +85,4 @@ namespace Ocelot.UnitTests.Authorization
, Times.Once);
}
}
}
}

View File

@ -1,12 +1,9 @@
using System.Collections.Generic;
using System.Security.Claims;
using Ocelot.Authorisation;
using Ocelot.Configuration;
using Ocelot.Authorisation;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Security.Claims;
using TestStack.BDDfy;
using Xunit;
@ -143,4 +140,4 @@ namespace Ocelot.UnitTests.Authorization
_result.Data.ShouldBe(false);
}
}
}
}

View File

@ -1,31 +1,37 @@
using System.Net.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Ocelot.Cache;
using Ocelot.Middleware;
using Shouldly;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Cache {
public class CacheKeyGeneratorTests {
namespace Ocelot.UnitTests.Cache
{
public class CacheKeyGeneratorTests
{
private readonly ICacheKeyGenerator _cacheKeyGenerator;
private readonly DownstreamContext _downstreamContext;
public CacheKeyGeneratorTests() {
public CacheKeyGeneratorTests()
{
_cacheKeyGenerator = new CacheKeyGenerator();
_cacheKeyGenerator = new CacheKeyGenerator();
_downstreamContext = new DownstreamContext(new DefaultHttpContext()) {
_downstreamContext = new DownstreamContext(new DefaultHttpContext())
{
DownstreamRequest = new Ocelot.Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"))
};
}
[Fact]
public void should_generate_cache_key_from_context() {
public void should_generate_cache_key_from_context()
{
this.Given(x => x.GivenCacheKeyFromContext(_downstreamContext))
.BDDfy();
}
private void GivenCacheKeyFromContext(DownstreamContext context) {
private void GivenCacheKeyFromContext(DownstreamContext context)
{
string generatedCacheKey = _cacheKeyGenerator.GenerateRequestCacheKey(context);
string cachekey = MD5Helper.GenerateMd5("GET-https://some.url/blah?abcd=123");
generatedCacheKey.ShouldBe(cachekey);

View File

@ -1,9 +1,9 @@
namespace Ocelot.UnitTests.Cache
{
using System;
using System.Threading;
using Ocelot.Cache;
using Shouldly;
using System;
using System.Threading;
using Xunit;
public class InMemoryCacheTests
@ -68,7 +68,7 @@
result.ShouldBeNull();
}
class Fake
private class Fake
{
public Fake(int value)
{

View File

@ -1,9 +1,5 @@
namespace Ocelot.UnitTests.Cache
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Cache;
@ -13,15 +9,18 @@
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Middleware;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using System.Net;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Middleware;
public class OutputCacheMiddlewareTests
{
private readonly Mock<IOcelotCache<CachedResponse>> _cache;
private readonly Mock<IOcelotCache<CachedResponse>> _cache;
private readonly Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private OutputCacheMiddleware _middleware;
@ -119,7 +118,7 @@
.Build())
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(), reRoute);
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;

View File

@ -1,9 +1,7 @@
using System.Collections.Generic;
using Ocelot.Cache;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.File;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -44,15 +42,15 @@ namespace Ocelot.UnitTests.Cache
.When(_ => WhenICreateTheRegion())
.Then(_ => ThenTheRegionIs("region"))
.BDDfy();
}
}
private void GivenTheReRoute(FileReRoute reRoute)
{
_reRoute = reRoute;
}
private void WhenICreateTheRegion()
{
{
RegionCreator regionCreator = new RegionCreator();
_result = regionCreator.Create(_reRoute);
}
@ -62,4 +60,4 @@ namespace Ocelot.UnitTests.Cache
_result.ShouldBe(expected);
}
}
}
}

View File

@ -1,8 +1,5 @@
namespace Ocelot.UnitTests.CacheManager
{
using System;
using System.Collections.Generic;
using System.Linq;
using global::CacheManager.Core;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
@ -14,6 +11,9 @@
using Ocelot.Configuration.File;
using Ocelot.DependencyInjection;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
@ -79,7 +79,8 @@
{
try
{
_ocelotBuilder.AddCacheManager(x => {
_ocelotBuilder.AddCacheManager(x =>
{
x.WithMaxRetries(_maxRetries);
x.WithDictionaryHandle();
});

View File

@ -1,10 +1,10 @@
namespace Ocelot.UnitTests.CacheManager
{
using System;
using global::CacheManager.Core;
using Moq;
using Ocelot.Cache.CacheManager;
using Shouldly;
using System;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,11 +1,5 @@
namespace Ocelot.UnitTests.CacheManager
{
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using global::CacheManager.Core;
using Microsoft.AspNetCore.Http;
using Moq;
@ -17,6 +11,12 @@
using Ocelot.Logging;
using Ocelot.Middleware;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -52,7 +52,7 @@
{
var content = new StringContent("{\"Test\": 1}")
{
Headers = { ContentType = new MediaTypeHeaderValue("application/json")}
Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
};
var response = new DownstreamResponse(content, HttpStatusCode.OK, new List<KeyValuePair<string, IEnumerable<string>>>(), "fooreason");

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Claims;
using Ocelot.Configuration;
@ -8,6 +6,8 @@ using Ocelot.Errors;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Security.Claims;
using TestStack.BDDfy;
using Xunit;
@ -131,7 +131,7 @@ namespace Ocelot.UnitTests.Claims
_result.IsError.ShouldBe(true);
}
class AnyError : Error
private class AnyError : Error
{
public AnyError()
: base("blahh", OcelotErrorCode.UnknownError)
@ -139,4 +139,4 @@ namespace Ocelot.UnitTests.Claims
}
}
}
}
}

View File

@ -2,8 +2,6 @@
namespace Ocelot.UnitTests.Claims
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Claims;
@ -14,6 +12,8 @@ namespace Ocelot.UnitTests.Claims
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,15 +1,15 @@
namespace Ocelot.UnitTests.Configuration
{
using System.Collections.Generic;
using System.Net.Http;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Values;
using Shouldly;
using System.Collections.Generic;
using System.Net.Http;
using TestStack.BDDfy;
using Values;
using Xunit;
public class AggregatesCreatorTests
@ -112,13 +112,13 @@ namespace Ocelot.UnitTests.Configuration
_result[1].UpstreamTemplatePattern.ShouldBe(_aggregate2Utp);
_result[1].Aggregator.ShouldBe(_fileConfiguration.Aggregates[1].Aggregator);
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[2].DownstreamReRoute[0]);
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[3].DownstreamReRoute[0]);
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[3].DownstreamReRoute[0]);
}
private void ThenTheUtpCreatorIsCalledCorrectly()
{
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[0]), Times.Once);
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[1]), Times.Once);
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[1]), Times.Once);
}
private void GivenTheUtpCreatorReturns()

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -54,9 +54,9 @@ namespace Ocelot.UnitTests.Configuration
}
private void ThenTheFollowingConfigIsReturned(AuthenticationOptions expected)
{
_result.AllowedScopes.ShouldBe(expected.AllowedScopes);
{
_result.AllowedScopes.ShouldBe(expected.AllowedScopes);
_result.AuthenticationProviderKey.ShouldBe(expected.AuthenticationProviderKey);
}
}
}
}

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Ocelot.Configuration;
using Ocelot.Configuration;
using Ocelot.Configuration.Parser;
using Ocelot.Errors;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
@ -114,4 +114,4 @@ namespace Ocelot.UnitTests.Configuration
_dictionary = dictionary;
}
}
}
}

View File

@ -1,5 +1,3 @@
using System.Collections.Generic;
using System.Linq;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
@ -8,6 +6,8 @@ using Ocelot.Errors;
using Ocelot.Logging;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
@ -16,7 +16,7 @@ namespace Ocelot.UnitTests.Configuration
public class ClaimsToThingCreatorTests
{
private readonly Mock<IClaimToThingConfigurationParser> _configParser;
private Dictionary<string,string> _claimsToThings;
private Dictionary<string, string> _claimsToThings;
private ClaimsToThingCreator _claimsToThingsCreator;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private List<ClaimToThing> _result;
@ -36,13 +36,13 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_return_claims_to_things()
{
var userInput = new Dictionary<string,string>()
var userInput = new Dictionary<string, string>()
{
{"CustomerId", "Claims[CustomerId] > value"}
};
var claimsToThing = new OkResponse<ClaimToThing>(new ClaimToThing("CustomerId", "CustomerId", "", 0));
var claimsToThing = new OkResponse<ClaimToThing>(new ClaimToThing("CustomerId", "CustomerId", "", 0));
this.Given(x => x.GivenTheFollowingDictionary(userInput))
.And(x => x.GivenTheConfigHeaderExtractorReturns(claimsToThing))
.When(x => x.WhenIGetTheThings())
@ -53,14 +53,14 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_log_error_if_cannot_parse_claim_to_thing()
{
var userInput = new Dictionary<string,string>()
{
var userInput = new Dictionary<string, string>()
{
{"CustomerId", "Claims[CustomerId] > value"}
};
var claimsToThing = new ErrorResponse<ClaimToThing>(It.IsAny<Error>());
var claimsToThing = new ErrorResponse<ClaimToThing>(It.IsAny<Error>());
this.Given(x => x.GivenTheFollowingDictionary(userInput))
.And(x => x.GivenTheConfigHeaderExtractorReturns(claimsToThing))
.When(x => x.WhenIGetTheThings())
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.Configuration
_result.Count.ShouldBeGreaterThan(0);
}
private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
private void GivenTheFollowingDictionary(Dictionary<string, string> claimsToThings)
{
_claimsToThings = claimsToThings;
}
@ -108,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
}
}
}
}

View File

@ -1,6 +1,5 @@
namespace Ocelot.UnitTests.Configuration
{
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
@ -8,6 +7,7 @@ namespace Ocelot.UnitTests.Configuration
using Ocelot.Configuration.File;
using Ocelot.DependencyInjection;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,17 +1,17 @@
namespace Ocelot.UnitTests.Configuration
{
using Microsoft.AspNetCore.Hosting;
using Moq;
using Newtonsoft.Json;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Repository;
using Shouldly;
using System;
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration.File;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using Newtonsoft.Json;
using System.IO;
using System.Threading;
using Microsoft.AspNetCore.Hosting;
using Ocelot.Configuration.Repository;
using TestStack.BDDfy;
using Xunit;
public class DiskFileConfigurationRepositoryTests : IDisposable
{
@ -26,6 +26,7 @@ namespace Ocelot.UnitTests.Configuration
// cant pick it up if they run in parralel..and the semaphore stops them running at the same time...sigh
// these are not really unit tests but whatever...
private string _environmentName = "DEV.DEV";
private static SemaphoreSlim _semaphore;
public DiskFileConfigurationRepositoryTests()
@ -102,7 +103,7 @@ namespace Ocelot.UnitTests.Configuration
private void GivenTheUserAddedOcelotJson()
{
_ocelotJsonPath = $"{AppContext.BaseDirectory}/ocelot.json";
_ocelotJsonPath = $"{AppContext.BaseDirectory}/ocelot.json";
if (File.Exists(_ocelotJsonPath))
{
@ -136,7 +137,7 @@ namespace Ocelot.UnitTests.Configuration
_result.GlobalConfiguration.ServiceDiscoveryProvider.Host.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Host);
_result.GlobalConfiguration.ServiceDiscoveryProvider.Port.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Port);
for(var i = 0; i < _result.ReRoutes.Count; i++)
for (var i = 0; i < _result.ReRoutes.Count; i++)
{
for (int j = 0; j < _result.ReRoutes[i].DownstreamHostAndPorts.Count; j++)
{
@ -176,7 +177,7 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheConfigurationJsonIsIndented(FileConfiguration expecteds)
{
var path = !string.IsNullOrEmpty(_environmentSpecificPath) ? _environmentSpecificPath : _environmentSpecificPath = $"{AppContext.BaseDirectory}/ocelot{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";
var resultText = File.ReadAllText(path);
var expectedText = JsonConvert.SerializeObject(expecteds, Formatting.Indented);
resultText.ShouldBe(expectedText);
@ -193,7 +194,7 @@ namespace Ocelot.UnitTests.Configuration
_result.GlobalConfiguration.ServiceDiscoveryProvider.Host.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Host);
_result.GlobalConfiguration.ServiceDiscoveryProvider.Port.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Port);
for(var i = 0; i < _result.ReRoutes.Count; i++)
for (var i = 0; i < _result.ReRoutes.Count; i++)
{
for (int j = 0; j < _result.ReRoutes[i].DownstreamHostAndPorts.Count; j++)
{

View File

@ -1,9 +1,8 @@
using System.Collections.Generic;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -47,7 +46,7 @@ namespace Ocelot.UnitTests.Configuration
new FileHostAndPort
{
Host = "test",
Port = 80
Port = 80
}
},
};
@ -87,8 +86,8 @@ namespace Ocelot.UnitTests.Configuration
{
new DownstreamHostAndPort("test", 80),
new DownstreamHostAndPort("west", 443)
};
};
this.Given(x => GivenTheFollowingReRoute(reRoute))
.When(x => WhenICreate())
.Then(x => TheThenFollowingIsReturned(expected))
@ -119,4 +118,4 @@ namespace Ocelot.UnitTests.Configuration
}
}
}
}
}

View File

@ -1,12 +1,12 @@
namespace Ocelot.UnitTests.Configuration
{
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,19 +1,18 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Repository;
using Ocelot.Configuration.Setter;
using Ocelot.Logging;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Threading;
using TestStack.BDDfy;
using Xunit;
using Shouldly;
using static Ocelot.Infrastructure.Wait;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration;
namespace Ocelot.UnitTests.Configuration
{
@ -44,20 +43,21 @@ namespace Ocelot.UnitTests.Configuration
_poller = new FileConfigurationPoller(_factory.Object, _repo.Object, _config.Object, _internalConfigRepo.Object, _internalConfigCreator.Object);
_poller.StartAsync(new CancellationToken());
}
[Fact]
public void should_start()
{
this.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
.BDDfy();
this.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
.BDDfy();
}
[Fact]
public void should_call_setter_when_gets_new_config()
{
var newConfig = new FileConfiguration {
var newConfig = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
{
new FileReRoute
{
DownstreamHostAndPorts = new List<FileHostAndPort>
@ -143,14 +143,15 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheSetterIsCalled(FileConfiguration fileConfig, int times)
{
var result = WaitFor(4000).Until(() => {
var result = WaitFor(4000).Until(() =>
{
try
{
_internalConfigRepo.Verify(x => x.AddOrReplace(_internalConfig), Times.Exactly(times));
_internalConfigCreator.Verify(x => x.Create(fileConfig), Times.Exactly(times));
return true;
}
catch(Exception)
catch (Exception)
{
return false;
}
@ -160,14 +161,15 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheSetterIsCalledAtLeast(FileConfiguration fileConfig, int times)
{
var result = WaitFor(4000).Until(() => {
var result = WaitFor(4000).Until(() =>
{
try
{
_internalConfigRepo.Verify(x => x.AddOrReplace(_internalConfig), Times.AtLeast(times));
_internalConfigCreator.Verify(x => x.Create(fileConfig), Times.AtLeast(times));
return true;
}
catch(Exception)
catch (Exception)
{
return false;
}

View File

@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
@ -10,6 +8,7 @@ using Ocelot.Configuration.Setter;
using Ocelot.Errors;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -22,7 +21,7 @@ namespace Ocelot.UnitTests.Configuration
private Mock<IInternalConfigurationRepository> _configRepo;
private Mock<IInternalConfigurationCreator> _configCreator;
private Response<IInternalConfiguration> _configuration;
private object _result;
private object _result;
private Mock<IFileConfigurationRepository> _repo;
public FileConfigurationSetterTests()
@ -109,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.AddOrReplace(_configuration.Data), Times.Once);
}
}
}
}

View File

@ -1,20 +1,20 @@
namespace Ocelot.UnitTests.Configuration
{
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Validator;
using Ocelot.Errors;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using Ocelot.Errors;
using System.Threading.Tasks;
using Ocelot.UnitTests.Responder;
using System.Linq;
public class FileInternalConfigurationCreatorTests
{

View File

@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System;
using System.Security.Cryptography;
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using Shouldly;
using Xunit;
namespace Ocelot.UnitTests.Configuration
@ -20,8 +19,8 @@ namespace Ocelot.UnitTests.Configuration
rng.GetBytes(salt);
}
var storedSalt = Convert.ToBase64String(salt);
var storedSalt = Convert.ToBase64String(salt);
var storedHash = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: password,
salt: salt,
@ -30,4 +29,4 @@ namespace Ocelot.UnitTests.Configuration
numBytesRequested: 256 / 8));
}
}
}
}

View File

@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Infrastructure;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -43,8 +40,8 @@ namespace Ocelot.UnitTests.Configuration
{
{"Test", "Test, Chicken"},
{"Moop", "o, a"}
},
DownstreamHeaderTransform = new Dictionary<string, string>
},
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Pop", "West, East"},
{"Bop", "e, r"}
@ -96,8 +93,8 @@ namespace Ocelot.UnitTests.Configuration
public void should_use_base_url_placeholder()
{
var reRoute = new FileReRoute
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Location", "http://www.bbc.co.uk/, {BaseUrl}"},
}
@ -153,8 +150,8 @@ namespace Ocelot.UnitTests.Configuration
public void should_use_base_url_partial_placeholder()
{
var reRoute = new FileReRoute
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Location", "http://www.bbc.co.uk/pay, {BaseUrl}pay"},
}
@ -176,8 +173,8 @@ namespace Ocelot.UnitTests.Configuration
public void should_add_trace_id_header()
{
var reRoute = new FileReRoute
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Trace-Id", "{TraceId}"},
}
@ -244,8 +241,8 @@ namespace Ocelot.UnitTests.Configuration
{
_result.AddHeadersToDownstream[0].Key.ShouldBe(addHeader.Key);
_result.AddHeadersToDownstream[0].Value.ShouldBe(addHeader.Value);
}
}
private void ThenTheFollowingAddHeaderToUpstreamIsReturned(AddHeader addHeader)
{
_result.AddHeadersToUpstream[0].Key.ShouldBe(addHeader.Key);
@ -254,8 +251,8 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheFollowingDownstreamIsReturned(List<HeaderFindAndReplace> downstream)
{
_result.Downstream.Count.ShouldBe(downstream.Count);
_result.Downstream.Count.ShouldBe(downstream.Count);
for (int i = 0; i < _result.Downstream.Count; i++)
{
var result = _result.Downstream[i];
@ -264,7 +261,7 @@ namespace Ocelot.UnitTests.Configuration
result.Index.ShouldBe(expected.Index);
result.Key.ShouldBe(expected.Key);
result.Replace.ShouldBe(expected.Replace);
}
}
}
private void GivenTheReRoute(FileReRoute reRoute)
@ -279,8 +276,8 @@ namespace Ocelot.UnitTests.Configuration
private void ThenTheFollowingUpstreamIsReturned(List<HeaderFindAndReplace> expecteds)
{
_result.Upstream.Count.ShouldBe(expecteds.Count);
_result.Upstream.Count.ShouldBe(expecteds.Count);
for (int i = 0; i < _result.Upstream.Count; i++)
{
var result = _result.Upstream[i];
@ -292,4 +289,4 @@ namespace Ocelot.UnitTests.Configuration
}
}
}
}
}

View File

@ -1,20 +1,19 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Requester;
using Shouldly;
using System;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Configuration
{
using Microsoft.AspNetCore.Http;
using Ocelot.Logging;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.Logging;
public class HttpHandlerOptionsCreatorTests
{
@ -34,7 +33,7 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_not_use_tracing_if_fake_tracer_registered()
{
var fileReRoute = new FileReRoute
var fileReRoute = new FileReRoute
{
HttpHandlerOptions = new FileHttpHandlerOptions
{
@ -53,7 +52,7 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_use_tracing_if_real_tracer_registered()
{
var fileReRoute = new FileReRoute
var fileReRoute = new FileReRoute
{
HttpHandlerOptions = new FileHttpHandlerOptions
{
@ -165,7 +164,7 @@ namespace Ocelot.UnitTests.Configuration
_httpHandlerOptionsCreator = new HttpHandlerOptionsCreator(_serviceProvider);
}
class FakeTracer : ITracer
private class FakeTracer : ITracer
{
public void Event(HttpContext httpContext, string @event)
{

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using Ocelot.Configuration;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Repository;
using Ocelot.Responses;
using Shouldly;
using System;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -71,7 +71,7 @@ namespace Ocelot.UnitTests.Configuration
_result.IsError.ShouldBeFalse();
}
class FakeConfig : IInternalConfiguration
private class FakeConfig : IInternalConfiguration
{
private readonly string _downstreamTemplatePath;
@ -100,15 +100,15 @@ namespace Ocelot.UnitTests.Configuration
}
}
public string AdministrationPath {get;}
public string AdministrationPath { get; }
public ServiceProviderConfiguration ServiceProviderConfiguration => throw new NotImplementedException();
public string RequestId {get;}
public string RequestId { get; }
public LoadBalancerOptions LoadBalancerOptions { get; }
public string DownstreamScheme { get; }
public QoSOptions QoSOptions { get; }
public HttpHandlerOptions HttpHandlerOptions { get; }
}
}
}
}

View File

@ -17,8 +17,8 @@ namespace Ocelot.UnitTests.Configuration
public QoSOptionsCreatorTests()
{
_creator = new QoSOptionsCreator();
}
}
[Fact]
public void should_create_qos_options()
{
@ -26,7 +26,7 @@ namespace Ocelot.UnitTests.Configuration
{
QoSOptions = new FileQoSOptions
{
ExceptionsAllowedBeforeBreaking = 1,
ExceptionsAllowedBeforeBreaking = 1,
DurationOfBreak = 1,
TimeoutValue = 1
}

View File

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ocelot.Configuration;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.LoadBalancer.LoadBalancers;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
@ -44,7 +44,7 @@ namespace Ocelot.UnitTests.Configuration
var reRoute = new FileReRoute
{
UpstreamPathTemplate = "/api/product",
UpstreamHttpMethod = new List<string> {"GET", "POST", "PUT"},
UpstreamHttpMethod = new List<string> { "GET", "POST", "PUT" },
DownstreamHostAndPorts = new List<FileHostAndPort>
{
new FileHostAndPort
@ -80,6 +80,5 @@ namespace Ocelot.UnitTests.Configuration
{
_result.ShouldBe(expected);
}
}
}

View File

@ -1,11 +1,11 @@
namespace Ocelot.UnitTests.Configuration
{
using System.Collections.Generic;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -19,7 +19,7 @@ namespace Ocelot.UnitTests.Configuration
{
_creator = new ReRouteOptionsCreator();
}
[Fact]
public void should_create_re_route_options()
{

View File

@ -1,8 +1,5 @@
namespace Ocelot.UnitTests.Configuration
{
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using Ocelot.Cache;
using Ocelot.Configuration;
@ -11,6 +8,8 @@
using Ocelot.Configuration.File;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
@ -31,7 +30,7 @@
private Mock<ILoadBalancerOptionsCreator> _lboCreator;
private Mock<IReRouteKeyCreator> _rrkCreator;
private Mock<ISecurityOptionsCreator> _soCreator;
private FileConfiguration _fileConfig;
private FileConfiguration _fileConfig;
private ReRouteOptions _rro;
private string _requestId;
private string _rrk;

View File

@ -56,7 +56,7 @@ namespace Ocelot.UnitTests.Configuration
var reRoute = new FileReRoute
{
RequestIdKey = "cheese"
};
};
var globalConfig = new FileGlobalConfiguration
{
RequestIdKey = "test"
@ -89,4 +89,4 @@ namespace Ocelot.UnitTests.Configuration
_result.ShouldBe(expected);
}
}
}
}

View File

@ -2,9 +2,7 @@
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;
using TestStack.BDDfy;
using Xunit;
@ -49,7 +47,6 @@ namespace Ocelot.UnitTests.Configuration
_fileReRoute = reRoute;
}
private void WhenICreate()
{
_result = _creator.Create(_fileReRoute.SecurityOptions);
@ -67,6 +64,5 @@ namespace Ocelot.UnitTests.Configuration
_result.IPBlockedList[i].ShouldBe(expected.IPBlockedList[i]);
}
}
}
}

View File

@ -31,7 +31,7 @@ namespace Ocelot.UnitTests.Configuration
Type = "ServiceFabric",
Token = "testtoken",
ConfigurationKey = "woo",
Namespace ="default"
Namespace = "default"
}
};
@ -48,7 +48,7 @@ namespace Ocelot.UnitTests.Configuration
.When(x => x.WhenICreate())
.Then(x => x.ThenTheConfigIs(expected))
.BDDfy();
}
}
private void GivenTheFollowingGlobalConfig(FileGlobalConfiguration fileGlobalConfig)
{

View File

@ -101,11 +101,11 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_set_upstream_template_pattern_to_respect_case_sensitivity()
{
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/PRODUCTS/{productId}",
ReRouteIsCaseSensitive = true
};
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/PRODUCTS/{productId}",
ReRouteIsCaseSensitive = true
};
this.Given(x => x.GivenTheFollowingFileReRoute(fileReRoute))
.When(x => x.WhenICreateTheTemplatePattern())
.Then(x => x.ThenTheFollowingIsReturned("^/PRODUCTS/.+$"))

View File

@ -1,25 +1,25 @@
namespace Ocelot.UnitTests.Configuration.Validation
{
using System.Collections.Generic;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Validator;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Requester;
using Requester;
using Ocelot.Responses;
using Ocelot.ServiceDiscovery;
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
using Ocelot.ServiceDiscovery;
using Requester;
using Shouldly;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
public class FileConfigurationFluentValidatorTests
{
@ -126,7 +126,7 @@
.Then(x => x.ThenTheResultIsValid())
.BDDfy();
}
[Fact]
public void configuration_is_invalid_if_service_discovery_options_specified_but_no_service_discovery_handler()
{
@ -300,7 +300,7 @@
.Then(x => x.ThenTheResultIsValid())
.BDDfy();
}
[Fact]
public void configuration_is_invalid_if_qos_options_specified_but_no_qos_handler()
{
@ -1382,7 +1382,7 @@
private void GivenAQoSHandler()
{
var collection = new ServiceCollection();
QosDelegatingHandlerDelegate del = (a,b) => new FakeDelegatingHandler();
QosDelegatingHandlerDelegate del = (a, b) => new FakeDelegatingHandler();
collection.AddSingleton<QosDelegatingHandlerDelegate>(del);
var provider = collection.BuildServiceProvider();
_configurationValidator = new FileConfigurationFluentValidator(provider, new ReRouteFluentValidator(_authProvider.Object, new HostAndPortValidator(), new FileQoSOptionsFluentValidator(provider)), new FileGlobalConfigurationFluentValidator(new FileQoSOptionsFluentValidator(provider)));
@ -1391,7 +1391,7 @@
private void GivenAServiceDiscoveryHandler()
{
var collection = new ServiceCollection();
ServiceDiscoveryFinderDelegate del = (a,b,c) => new FakeServiceDiscoveryProvider();
ServiceDiscoveryFinderDelegate del = (a, b, c) => new FakeServiceDiscoveryProvider();
collection.AddSingleton<ServiceDiscoveryFinderDelegate>(del);
var provider = collection.BuildServiceProvider();
_configurationValidator = new FileConfigurationFluentValidator(provider, new ReRouteFluentValidator(_authProvider.Object, new HostAndPortValidator(), new FileQoSOptionsFluentValidator(provider)), new FileGlobalConfigurationFluentValidator(new FileQoSOptionsFluentValidator(provider)));

View File

@ -1,7 +1,5 @@
using System;
using FluentValidation.Results;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Validator;
using Ocelot.Requester;
@ -64,7 +62,6 @@ namespace Ocelot.UnitTests.Configuration.Validation
.Then(_ => ThenTheResultIsInValid())
.And(_ => ThenTheErrorIs())
.BDDfy();
}
private void ThenTheErrorIs()

View File

@ -1,4 +1,3 @@
using System;
using FluentValidation.Results;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Validator;

View File

@ -1,8 +1,5 @@
namespace Ocelot.UnitTests.Configuration.Validation
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentValidation.Results;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
@ -11,6 +8,9 @@
using Ocelot.Configuration.Validator;
using Ocelot.Requester;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -342,7 +342,7 @@
_result.Errors.ShouldContain(x => x.ErrorMessage == expected);
}
class FakeAutheHandler : IAuthenticationHandler
private class FakeAutheHandler : IAuthenticationHandler
{
public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context)
{

View File

@ -1,10 +1,5 @@
namespace Ocelot.UnitTests.Consul
{
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using global::Consul;
using Moq;
using Newtonsoft.Json;
@ -17,6 +12,11 @@
using Provider.Consul;
using Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,9 +1,5 @@
namespace Ocelot.UnitTests.Consul
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using global::Consul;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -13,6 +9,10 @@
using Ocelot.Logging;
using Provider.Consul;
using Shouldly;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TestStack.BDDfy;
using Values;
using Xunit;

View File

@ -1,7 +1,5 @@
namespace Ocelot.UnitTests.Consul
{
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration;
@ -9,6 +7,8 @@
using Ocelot.DependencyInjection;
using Provider.Consul;
using Shouldly;
using System;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,13 +1,13 @@
namespace Ocelot.UnitTests.Consul
{
using System;
using System.Collections.Generic;
using Moq;
using Ocelot.Infrastructure;
using Ocelot.Logging;
using Ocelot.ServiceDiscovery.Providers;
using Provider.Consul;
using Shouldly;
using System;
using System.Collections.Generic;
using TestStack.BDDfy;
using Values;
using Xunit;
@ -58,7 +58,8 @@
{
_provider = new PollConsul(_delay, _factory.Object, _consulServiceDiscoveryProvider.Object);
var result = Wait.WaitFor(3000).Until(() => {
var result = Wait.WaitFor(3000).Until(() =>
{
try
{
_result = _provider.Get().GetAwaiter().GetResult();

View File

@ -1,12 +1,12 @@
namespace Ocelot.UnitTests.Consul
{
using System;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Logging;
using Provider.Consul;
using Shouldly;
using System;
using Xunit;
public class ProviderFactoryTests

View File

@ -1,14 +1,14 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Setter;
using Ocelot.Errors;
using Ocelot.Responses;
using Shouldly;
using System;
using TestStack.BDDfy;
using Xunit;
using Shouldly;
using Ocelot.Configuration;
namespace Ocelot.UnitTests.Controllers
{
@ -29,8 +29,8 @@ namespace Ocelot.UnitTests.Controllers
_repo = new Mock<IFileConfigurationRepository>();
_setter = new Mock<IFileConfigurationSetter>();
_controller = new FileConfigurationController(_repo.Object, _setter.Object, _provider.Object);
}
}
[Fact]
public void should_get_file_configuration()
{
@ -45,15 +45,15 @@ namespace Ocelot.UnitTests.Controllers
[Fact]
public void should_return_error_when_cannot_get_config()
{
var expected = new Responses.ErrorResponse<FileConfiguration>(It.IsAny<Error>());
this.Given(x => x.GivenTheGetConfigurationReturns(expected))
.When(x => x.WhenIGetTheFileConfiguration())
.Then(x => x.TheTheGetFileConfigurationIsCalledCorrectly())
.And(x => x.ThenTheResponseIs<BadRequestObjectResult>())
.BDDfy();
}
var expected = new Responses.ErrorResponse<FileConfiguration>(It.IsAny<Error>());
this.Given(x => x.GivenTheGetConfigurationReturns(expected))
.When(x => x.WhenIGetTheFileConfiguration())
.Then(x => x.TheTheGetFileConfigurationIsCalledCorrectly())
.And(x => x.ThenTheResponseIs<BadRequestObjectResult>())
.BDDfy();
}
[Fact]
public void should_post_file_configuration()
{
@ -103,8 +103,8 @@ namespace Ocelot.UnitTests.Controllers
}
private void ThenTheResponseIs<T>()
{
_result.ShouldBeOfType<T>();
{
_result.ShouldBeOfType<T>();
}
private void GivenTheGetConfigurationReturns(Ocelot.Responses.Response<FileConfiguration> fileConfiguration)
@ -120,16 +120,16 @@ namespace Ocelot.UnitTests.Controllers
}
private void TheTheGetFileConfigurationIsCalledCorrectly()
{
_repo
.Verify(x => x.Get(), Times.Once);
{
_repo
.Verify(x => x.Get(), Times.Once);
}
class FakeError : Error
private class FakeError : Error
{
public FakeError() : base(string.Empty, OcelotErrorCode.CannotAddDataError)
{
}
}
}
}
}

View File

@ -1,12 +1,9 @@
using Xunit;
using Microsoft.AspNetCore.Mvc;
using Moq;
using Ocelot.Cache;
using Shouldly;
using TestStack.BDDfy;
using Ocelot.Cache;
using System;
using Moq;
using System.Net.Http;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Xunit;
namespace Ocelot.UnitTests.Controllers
{
@ -24,10 +21,10 @@ namespace Ocelot.UnitTests.Controllers
[Fact]
public void should_delete_key()
{
this.When(_ => WhenIDeleteTheKey("a"))
.Then(_ => ThenTheKeyIsDeleted("a"))
.BDDfy();
{
this.When(_ => WhenIDeleteTheKey("a"))
.Then(_ => ThenTheKeyIsDeleted("a"))
.BDDfy();
}
private void ThenTheKeyIsDeleted(string key)
@ -42,4 +39,4 @@ namespace Ocelot.UnitTests.Controllers
_result = _controller.Delete(key);
}
}
}
}

View File

@ -1,16 +1,16 @@
namespace Ocelot.UnitTests.DependencyInjection
{
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Moq;
using Newtonsoft.Json;
using Ocelot.Configuration.File;
using Microsoft.Extensions.Configuration;
using Ocelot.DependencyInjection;
using Shouldly;
using System.Collections.Generic;
using System.IO;
using TestStack.BDDfy;
using Xunit;
using Moq;
using Microsoft.AspNetCore.Hosting;
public class ConfigurationBuilderExtensionsTests
{
@ -24,14 +24,13 @@
private FileConfiguration _envSpecific;
private Mock<IHostingEnvironment> _hostingEnvironment;
public ConfigurationBuilderExtensionsTests()
{
_hostingEnvironment = new Mock<IHostingEnvironment>();
// Clean up config files before each test
var subConfigFiles = new DirectoryInfo(".").GetFiles("ocelot.*.json");
foreach(var config in subConfigFiles)
foreach (var config in subConfigFiles)
{
config.Delete();
}
@ -313,10 +312,10 @@
private void GivenTheBaseUrl(string baseUrl)
{
#pragma warning disable CS0618
#pragma warning disable CS0618
var builder = new ConfigurationBuilder()
.AddOcelotBaseUrl(baseUrl);
#pragma warning restore CS0618
#pragma warning restore CS0618
_configuration = builder.Build();
}

View File

@ -1,22 +1,22 @@
namespace Ocelot.UnitTests.DependencyInjection
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration.Setter;
using Ocelot.DependencyInjection;
using Ocelot.Middleware.Multiplexer;
using Ocelot.Requester;
using Ocelot.UnitTests.Requester;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
using static Ocelot.UnitTests.Middleware.UserDefinedResponseAggregatorTests;
using Ocelot.Middleware.Multiplexer;
public class OcelotBuilderTests
{

View File

@ -1,19 +1,18 @@
namespace Ocelot.UnitTests.DownstreamRouteFinder
{
using System;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.LoadBalancer.LoadBalancers;
using Responses;
using TestStack.BDDfy;
using Ocelot.DownstreamRouteFinder.Finder;
using Xunit;
using Shouldly;
using Ocelot.Configuration;
using System.Net.Http;
using System.Collections.Generic;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
public class DownstreamRouteCreatorTests
{
@ -71,7 +70,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.Build();
var reRoutes = new List<ReRoute> { reRoute };
var configuration = new InternalConfiguration(reRoutes, "doesnt matter", null, "doesnt matter", _loadBalancerOptions, "http", _qoSOptions, _handlerOptions);
this.Given(_ => GivenTheConfiguration(configuration))
@ -224,7 +223,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
_result.Data.ReRoute.DownstreamReRoute[0].QosOptions.ShouldBe(_qoSOptions);
_result.Data.ReRoute.UpstreamTemplatePattern.ShouldNotBeNull();
_result.Data.ReRoute.DownstreamReRoute[0].UpstreamPathTemplate.ShouldNotBeNull();
}
private void ThenTheDownstreamPathIsForwardSlash()

View File

@ -1,7 +1,5 @@
namespace Ocelot.UnitTests.DownstreamRouteFinder
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
@ -11,13 +9,14 @@
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using Ocelot.Configuration.Repository;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
public class DownstreamRouteFinderMiddlewareTests
{
@ -53,12 +52,12 @@
var downstreamReRoute = new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
this.Given(x => x.GivenTheDownStreamRouteFinderReturns(
new DownstreamRoute(
new List<PlaceholderNameAndValue>(),
new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(downstreamReRoute)
.WithUpstreamHttpMethod(new List<string> { "Get" })

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using Moq;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
@ -8,6 +7,7 @@ using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -132,7 +132,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
var serviceProviderConfig = new ServiceProviderConfigurationBuilder().Build();
this.Given(x => x.GivenThereIsAnUpstreamUrlPath("matchInUrlMatcher/"))
.And(x =>x.GivenTheTemplateVariableAndNameFinderReturns(
.And(x => x.GivenTheTemplateVariableAndNameFinderReturns(
new OkResponse<List<PlaceholderNameAndValue>>(
new List<PlaceholderNameAndValue>())))
.And(x => x.GivenTheConfigurationIs(new List<ReRoute>
@ -174,7 +174,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
var serviceProviderConfig = new ServiceProviderConfigurationBuilder().Build();
this.Given(x => x.GivenThereIsAnUpstreamUrlPath("matchInUrlMatcher"))
.And(x =>x.GivenTheTemplateVariableAndNameFinderReturns(
.And(x => x.GivenTheTemplateVariableAndNameFinderReturns(
new OkResponse<List<PlaceholderNameAndValue>>(
new List<PlaceholderNameAndValue>())))
.And(x => x.GivenTheConfigurationIs(new List<ReRoute>
@ -303,7 +303,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
[Fact]
public void should_not_return_route()
{
{
var serviceProviderConfig = new ServiceProviderConfigurationBuilder().Build();
this.Given(x => x.GivenThereIsAnUpstreamUrlPath("dontMatchPath/"))
@ -317,7 +317,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.Build())
.WithUpstreamHttpMethod(new List<string> { "Get" })
.WithUpstreamPathTemplate(new UpstreamPathTemplate("somePath", 1, false, "someUpstreamPath"))
.Build(),
.Build(),
}, string.Empty, serviceProviderConfig
))
.And(x => x.GivenTheUrlMatcherReturns(new OkResponse<UrlMatch>(new UrlMatch(false))))
@ -762,7 +762,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
_result.Data.TemplatePlaceholderNameAndValues[i].Name.ShouldBe(expected.TemplatePlaceholderNameAndValues[i].Name);
_result.Data.TemplatePlaceholderNameAndValues[i].Value.ShouldBe(expected.TemplatePlaceholderNameAndValues[i].Value);
}
_result.IsError.ShouldBeFalse();
}
}

View File

@ -1,17 +1,17 @@
namespace Ocelot.UnitTests.DownstreamRouteFinder
{
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
using Ocelot.Configuration.Creator;
using Ocelot.Logging;
public class DownstreamRouteProviderFactoryTests
{

View File

@ -1,14 +1,14 @@
using System.Collections.Generic;
using System.Linq;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
{
public class UrlPathPlaceholderNameAndValueFinderTests
public class UrlPathPlaceholderNameAndValueFinderTests
{
private readonly IPlaceholderNameAndValueFinder _finder;
private string _downstreamUrlPath;
@ -34,7 +34,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_nothing_then_placeholder_no_value_is_blank()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{url}", "")
};
@ -49,7 +49,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_nothing_then_placeholder_value_is_test()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{url}", "test")
};
@ -64,7 +64,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void should_match_everything_in_path_with_query()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{everything}", "test/toot")
};
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void should_match_everything_in_path()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{everything}", "test/toot")
};
@ -95,7 +95,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_forward_slash_then_placeholder_no_value_is_blank()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{url}", "")
};
@ -110,7 +110,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_forward_slash()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
};
@ -124,7 +124,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_forward_slash_then_placeholder_then_another_value()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{url}", "1")
};
@ -264,7 +264,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_downstream_template_with_one_place_holder()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{productId}", "1")
};
@ -279,7 +279,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_downstream_template_with_two_place_holders()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{productId}", "1"),
new PlaceholderNameAndValue("{categoryId}", "2")
@ -295,7 +295,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_downstream_template_with_two_place_holders_seperated_by_something()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{productId}", "1"),
new PlaceholderNameAndValue("{categoryId}", "2")
@ -311,7 +311,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_downstream_template_with_three_place_holders_seperated_by_something()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{productId}", "1"),
new PlaceholderNameAndValue("{categoryId}", "2"),
@ -328,7 +328,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
[Fact]
public void can_match_down_stream_url_with_downstream_template_with_three_place_holders()
{
var expectedTemplates = new List<PlaceholderNameAndValue>
var expectedTemplates = new List<PlaceholderNameAndValue>
{
new PlaceholderNameAndValue("{productId}", "1"),
new PlaceholderNameAndValue("{categoryId}", "2")
@ -385,4 +385,4 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
_query = query;
}
}
}
}

View File

@ -1,25 +1,25 @@
namespace Ocelot.UnitTests.DownstreamUrlCreator
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.DownstreamUrlCreator.Middleware;
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using Shouldly;
using Microsoft.AspNetCore.Http;
using Ocelot.Request.Middleware;
using Ocelot.Configuration;
using Ocelot.Middleware;
public class DownstreamUrlCreatorMiddlewareTests
{
@ -49,7 +49,7 @@
{
var downstreamReRoute = new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.WithDownstreamScheme("https")
.Build();
@ -58,7 +58,7 @@
this.Given(x => x.GivenTheDownStreamRouteIs(
new DownstreamRoute(
new List<PlaceholderNameAndValue>(),
new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(downstreamReRoute)
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -307,7 +307,7 @@
.WithHost("localhost")
.WithPort(19081)
.Build();
this.Given(x => x.GivenTheDownStreamRouteIs(downstreamRoute))
.And(x => GivenTheServiceProviderConfigIs(config))
.And(x => x.GivenTheDownstreamRequestUriIs("http://localhost:19081?PartitionKind=test&PartitionKey=1"))
@ -350,8 +350,6 @@
.BDDfy();
}
private void GivenTheServiceProviderConfigIs(ServiceProviderConfiguration config)
{
var configuration = new InternalConfiguration(null, null, config, null, null, null, null, null);
@ -386,6 +384,7 @@
setup.Returns(response);
}
}
private void GivenTheUrlReplacerWillReturn(string path)
{
_downstreamPath = new OkResponse<DownstreamPath>(new DownstreamPath(path));

View File

@ -1,4 +1,3 @@
using System.Collections.Generic;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
@ -6,6 +5,7 @@ using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -27,7 +27,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
{
this.Given(x => x.GivenThereIsAUrlMatch(
new DownstreamRoute(
new List<PlaceholderNameAndValue>(),
new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -44,7 +44,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
{
this.Given(x => x.GivenThereIsAUrlMatch(
new DownstreamRoute(
new List<PlaceholderNameAndValue>(),
new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("/")
@ -60,7 +60,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
[Fact]
public void can_replace_url_no_slash()
{
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("api")
@ -76,7 +76,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
[Fact]
public void can_replace_url_one_slash()
{
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("api/")
@ -92,7 +92,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
[Fact]
public void can_replace_url_multiple_slash()
{
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("api/product/products/")
@ -113,7 +113,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
new PlaceholderNameAndValue("{productId}", "1")
};
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("productservice/products/{productId}/")
@ -134,7 +134,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
new PlaceholderNameAndValue("{productId}", "1")
};
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("productservice/products/{productId}/variants")
@ -156,7 +156,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
new PlaceholderNameAndValue("{variantId}", "12")
};
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("productservice/products/{productId}/variants/{variantId}")
@ -167,9 +167,9 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
.When(x => x.WhenIReplaceTheTemplateVariables())
.Then(x => x.ThenTheDownstreamUrlPathIsReturned("productservice/products/1/variants/12"))
.BDDfy();
}
[Fact]
}
[Fact]
public void can_replace_url_three_template_variable()
{
var templateVariables = new List<PlaceholderNameAndValue>()
@ -179,7 +179,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
new PlaceholderNameAndValue("{categoryId}", "34")
};
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
this.Given(x => x.GivenThereIsAUrlMatch(new DownstreamRoute(templateVariables,
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
.WithDownstreamPathTemplate("productservice/category/{categoryId}/products/{productId}/variants/{variantId}")
@ -207,4 +207,4 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator.UrlTemplateReplacer
_result.Data.Value.ShouldBe(expected);
}
}
}
}

View File

@ -1,4 +1,3 @@
using Ocelot.Errors;
using Ocelot.Infrastructure.RequestData;
using Shouldly;
using Xunit;
@ -15,4 +14,4 @@ namespace Ocelot.UnitTests.Errors
result.ShouldBe("message");
}
}
}
}

View File

@ -1,24 +1,24 @@
namespace Ocelot.UnitTests.Errors
{
using System;
using System.Net;
using System.Threading.Tasks;
using Ocelot.Errors.Middleware;
using Ocelot.Logging;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
using Ocelot.Errors;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
using Ocelot.Configuration.Repository;
using Ocelot.Errors;
using Ocelot.Errors.Middleware;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware;
using Shouldly;
using System;
using System.Net;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
public class ExceptionHandlerMiddlewareTests
{
bool _shouldThrowAnException;
private bool _shouldThrowAnException;
private readonly Mock<IInternalConfigurationRepository> _configRepo;
private readonly Mock<IRequestScopedDataRepository> _repo;
private Mock<IOcelotLoggerFactory> _loggerFactory;
@ -35,7 +35,8 @@ namespace Ocelot.UnitTests.Errors
_loggerFactory = new Mock<IOcelotLoggerFactory>();
_logger = new Mock<IOcelotLogger>();
_loggerFactory.Setup(x => x.CreateLogger<ExceptionHandlerMiddleware>()).Returns(_logger.Object);
_next = async context => {
_next = async context =>
{
await Task.CompletedTask;
if (_shouldThrowAnException)
@ -47,7 +48,7 @@ namespace Ocelot.UnitTests.Errors
};
_middleware = new ExceptionHandlerMiddleware(_next, _loggerFactory.Object, _configRepo.Object, _repo.Object);
}
[Fact]
public void NoDownstreamException()
{
@ -102,21 +103,21 @@ namespace Ocelot.UnitTests.Errors
[Fact]
public void should_throw_exception_if_config_provider_returns_error()
{
this.Given(_ => GivenAnExceptionWillNotBeThrownDownstream())
.And(_ => GivenTheConfigReturnsError())
.When(_ => WhenICallTheMiddlewareWithTheRequestIdKey("requestidkey", "1234"))
.Then(_ => ThenAnExceptionIsThrown())
.BDDfy();
this.Given(_ => GivenAnExceptionWillNotBeThrownDownstream())
.And(_ => GivenTheConfigReturnsError())
.When(_ => WhenICallTheMiddlewareWithTheRequestIdKey("requestidkey", "1234"))
.Then(_ => ThenAnExceptionIsThrown())
.BDDfy();
}
[Fact]
public void should_throw_exception_if_config_provider_throws()
{
this.Given(_ => GivenAnExceptionWillNotBeThrownDownstream())
.And(_ => GivenTheConfigThrows())
.When(_ => WhenICallTheMiddlewareWithTheRequestIdKey("requestidkey", "1234"))
.Then(_ => ThenAnExceptionIsThrown())
.BDDfy();
this.Given(_ => GivenAnExceptionWillNotBeThrownDownstream())
.And(_ => GivenTheConfigThrows())
.When(_ => WhenICallTheMiddlewareWithTheRequestIdKey("requestidkey", "1234"))
.Then(_ => ThenAnExceptionIsThrown())
.BDDfy();
}
private void WhenICallTheMiddlewareWithTheRequestIdKey(string key, string value)
@ -133,8 +134,8 @@ namespace Ocelot.UnitTests.Errors
private void GivenTheConfigThrows()
{
var ex = new Exception("outer", new Exception("inner"));
_configRepo
.Setup(x => x.Get()).Throws(ex);
_configRepo
.Setup(x => x.Get()).Throws(ex);
}
private void ThenAnExceptionIsThrown()
@ -186,7 +187,7 @@ namespace Ocelot.UnitTests.Errors
_repo.Verify(x => x.Add(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
class FakeError : Error
private class FakeError : Error
{
internal FakeError()
: base("meh", OcelotErrorCode.CannotAddDataError)

View File

@ -1,6 +1,5 @@
namespace Ocelot.UnitTests.Eureka
{
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.Extensions.DependencyInjection;
using Moq;
@ -11,6 +10,7 @@
using Responses;
using Shouldly;
using Steeltoe.Common.Discovery;
using System.Threading.Tasks;
using Xunit;
public class EurekaMiddlewareConfigurationProviderTests

View File

@ -1,12 +1,12 @@
namespace Ocelot.UnitTests.Eureka
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Moq;
using Provider.Eureka;
using Shouldly;
using Steeltoe.Common.Discovery;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Values;
using Xunit;

View File

@ -1,17 +1,17 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Moq;
using Moq;
using Ocelot.Configuration;
using Ocelot.Errors;
using Ocelot.Headers;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
using TestStack.BDDfy;
using Xunit;
using System.Net.Http;
using Ocelot.Request.Middleware;
namespace Ocelot.UnitTests.Headers
{
@ -97,7 +97,7 @@ namespace Ocelot.UnitTests.Headers
.Then(x => x.ThenTheResultIsError())
.BDDfy();
}
private void GivenClaims(List<Claim> claims)
{
_claims = claims;
@ -119,8 +119,8 @@ namespace Ocelot.UnitTests.Headers
_parser
.Setup(
x =>
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
It.IsAny<string>(),
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<int>()))
.Returns(_claimValue);
@ -147,9 +147,9 @@ namespace Ocelot.UnitTests.Headers
header.Value.First().ShouldBe(_claimValue.Data);
}
class AnyError : Error
private class AnyError : Error
{
public AnyError()
public AnyError()
: base("blahh", OcelotErrorCode.UnknownError)
{
}

View File

@ -1,12 +1,12 @@
namespace Ocelot.UnitTests.Headers
{
using Ocelot.Infrastructure;
using Ocelot.Logging;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration.Creator;
using Ocelot.Headers;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Logging;
using Responder;
using Responses;
using Shouldly;
@ -76,7 +76,6 @@
_logger.Verify(x => x.LogWarning($"Unable to add header to response {key}: {value}"), Times.Once);
}
private void GivenHttpRequestWithoutHeaders()
{
_context = new DefaultHttpContext
@ -109,7 +108,7 @@
_addedHeader = new AddHeader(headerKey, headerValue);
_addHeadersToRequest.SetHeadersOnDownstreamRequest(new[] { _addedHeader }, _context);
}
private void ThenTheHeaderGetsTakenOverToTheRequestHeaders()
{
var requestHeaders = _context.Request.Headers;

View File

@ -1,18 +1,17 @@
using Xunit;
using TestStack.BDDfy;
using Ocelot.Headers;
using System.Net.Http;
using System.Collections.Generic;
using System.Linq;
using Ocelot.Configuration.Creator;
using Moq;
using Ocelot.Responses;
using Ocelot.Configuration.Creator;
using Ocelot.Headers;
using Ocelot.Infrastructure;
using Ocelot.UnitTests.Responder;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Headers
{
@ -56,9 +55,9 @@ namespace Ocelot.UnitTests.Headers
{
new AddHeader("Trace-Id", "{TraceId}")
};
var traceId = "123";
var traceId = "123";
this.Given(_ => GivenAResponseMessage())
.And(_ => GivenTheTraceIdIs(traceId))
.And(_ => GivenTheAddHeaders(addHeaders))
@ -94,7 +93,7 @@ namespace Ocelot.UnitTests.Headers
{
new AddHeader("Trace-Id", "{TraceId}")
};
this.Given(_ => GivenAResponseMessage())
.And(_ => GivenTheTraceIdErrors())
.And(_ => GivenTheAddHeaders(addHeaders))

View File

@ -2,9 +2,6 @@
namespace Ocelot.UnitTests.Headers
{
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
@ -16,6 +13,9 @@ namespace Ocelot.UnitTests.Headers
using Ocelot.Logging;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -91,7 +91,7 @@ namespace Ocelot.UnitTests.Headers
_addHeaders
.Verify(x => x.SetHeadersOnDownstreamRequest(
It.IsAny<List<ClaimToThing>>(),
It.IsAny<IEnumerable<System.Security.Claims.Claim>>(),
It.IsAny<IEnumerable<System.Security.Claims.Claim>>(),
_downstreamContext.DownstreamRequest), Times.Once);
}
}

View File

@ -1,12 +1,11 @@
using Xunit;
using Shouldly;
using Ocelot.Headers.Middleware;
using TestStack.BDDfy;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using Ocelot.Responses;
using Ocelot.Configuration;
using Ocelot.Headers;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Headers
{
@ -54,8 +53,8 @@ namespace Ocelot.UnitTests.Headers
}
private void ThenTheHeadersAreNotReplaced()
{
_result.ShouldBeOfType<OkResponse>();
{
_result.ShouldBeOfType<OkResponse>();
foreach (var f in _fAndRs)
{
_context.Request.Headers.TryGetValue(f.Key, out var values);
@ -88,4 +87,4 @@ namespace Ocelot.UnitTests.Headers
}
}
}
}
}

View File

@ -1,22 +1,21 @@
namespace Ocelot.UnitTests.Headers
{
using Xunit;
using Ocelot.Logging;
using Ocelot.Headers.Middleware;
using TestStack.BDDfy;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using Moq;
using Ocelot.Configuration;
using Ocelot.DownstreamRouteFinder;
using Ocelot.Configuration.Builder;
using Ocelot.Headers;
using System.Net.Http;
using Ocelot.Authorisation.Middleware;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.Headers;
using Ocelot.Headers.Middleware;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using System.Threading.Tasks;
using Ocelot.Request.Middleware;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
public class HttpHeadersTransformationMiddlewareTests
{
@ -117,4 +116,4 @@ namespace Ocelot.UnitTests.Headers
_downstreamContext.HttpContext.Request.Headers.Add("test", "test");
}
}
}
}

View File

@ -1,21 +1,21 @@
namespace Ocelot.UnitTests.Headers
{
using Microsoft.AspNetCore.Http;
using Ocelot.Infrastructure;
using Ocelot.Middleware;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Request.Middleware;
using Xunit;
using Shouldly;
using TestStack.BDDfy;
using System.Net.Http;
using Ocelot.Headers;
using Moq;
using Ocelot.Configuration;
using System.Collections.Generic;
using Ocelot.Headers;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Moq;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
public class HttpResponseHeaderReplacerTests
{
@ -47,7 +47,7 @@ namespace Ocelot.UnitTests.Headers
new KeyValuePair<string, IEnumerable<string>>("test", new List<string> {"test"})
}, "");
var fAndRs = new List<HeaderFindAndReplace> {new HeaderFindAndReplace("test", "test", "chiken", 0)};
var fAndRs = new List<HeaderFindAndReplace> { new HeaderFindAndReplace("test", "test", "chiken", 0) };
this.Given(x => GivenTheHttpResponse(response))
.And(x => GivenTheFollowingHeaderReplacements(fAndRs))
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com/";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -107,7 +107,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com/";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -134,7 +134,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com/test/product";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -161,7 +161,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com/test/product";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -188,7 +188,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com:123/test/product";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -215,7 +215,7 @@ namespace Ocelot.UnitTests.Headers
const string downstreamUrl = "http://downstream.com:123/test/product";
var request =
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
new List<KeyValuePair<string, IEnumerable<string>>>()
@ -243,7 +243,7 @@ namespace Ocelot.UnitTests.Headers
private void ThenTheHeadersAreNotReplaced()
{
_result.ShouldBeOfType<OkResponse>();
_result.ShouldBeOfType<OkResponse>();
foreach (var f in _headerFindAndReplaces)
{
var values = _response.Headers.First(x => x.Key == f.Key);
@ -263,7 +263,7 @@ namespace Ocelot.UnitTests.Headers
private void WhenICallTheReplacer()
{
var context = new DownstreamContext(new DefaultHttpContext()) {DownstreamResponse = _response, DownstreamRequest = _request};
var context = new DownstreamContext(new DefaultHttpContext()) { DownstreamResponse = _response, DownstreamRequest = _request };
_result = _replacer.Replace(context, _headerFindAndReplaces);
}

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using Ocelot.Middleware;
using Ocelot.Middleware;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -49,4 +49,4 @@ namespace Ocelot.UnitTests.Headers
_headers.ShouldNotContain(x => x.Key == "transfer-encoding");
}
}
}
}

View File

@ -2,11 +2,11 @@
namespace Ocelot.UnitTests.Infrastructure
{
using System.Collections.Generic;
using System.Security.Claims;
using Ocelot.Infrastructure.Claims.Parser;
using Responses;
using Shouldly;
using System.Collections.Generic;
using System.Security.Claims;
using TestStack.BDDfy;
using Xunit;
@ -119,6 +119,6 @@ namespace Ocelot.UnitTests.Infrastructure
{
_result.Data.ShouldBe(expected.Data);
_result.IsError.ShouldBe(expected.IsError);
}
}
}
}
}

View File

@ -17,12 +17,12 @@ namespace Ocelot.UnitTests.Infrastructure
public HttpDataRepositoryTests()
{
_httpContext = new DefaultHttpContext();
_httpContextAccessor = new HttpContextAccessor{HttpContext = _httpContext};
_httpContextAccessor = new HttpContextAccessor { HttpContext = _httpContext };
_httpDataRepository = new HttpDataRepository(_httpContextAccessor);
}
/*
TODO - Additional tests -> Type mistmatch aka Add string, request int
TODO - Additional tests -> Type mistmatch aka Add string, request int
TODO - Additional tests -> HttpContent null. This should never happen
*/
@ -72,9 +72,9 @@ namespace Ocelot.UnitTests.Infrastructure
private void ThenTheResultIsAnErrorReposnse<T>(object resultValue)
{
_result.ShouldBeOfType<ErrorResponse<T>>();
((ErrorResponse<T>) _result).Data.ShouldBeNull();
((ErrorResponse<T>)_result).Data.ShouldBeNull();
((ErrorResponse<T>)_result).IsError.ShouldBe(true);
((ErrorResponse<T>) _result).Errors.ShouldHaveSingleItem()
((ErrorResponse<T>)_result).Errors.ShouldHaveSingleItem()
.ShouldBeOfType<CannotFindDataError>()
.Message.ShouldStartWith("Unable to find data for key: ");
}
@ -85,4 +85,4 @@ namespace Ocelot.UnitTests.Infrastructure
((OkResponse<T>)_result).Data.ShouldBe(resultValue);
}
}
}
}

View File

@ -1,6 +1,6 @@
using System.Threading.Tasks;
using Ocelot.Infrastructure;
using Shouldly;
using System.Threading.Tasks;
using Xunit;
namespace Ocelot.UnitTests.Infrastructure
@ -18,7 +18,8 @@ namespace Ocelot.UnitTests.Infrastructure
public async Task should_publish_with_delay()
{
var called = false;
_bus.Subscribe(x => {
_bus.Subscribe(x =>
{
called = true;
});
_bus.Publish(new object(), 1);
@ -30,7 +31,8 @@ namespace Ocelot.UnitTests.Infrastructure
public void should_not_be_publish_yet_as_no_delay_in_caller()
{
var called = false;
_bus.Subscribe(x => {
_bus.Subscribe(x =>
{
called = true;
});
_bus.Publish(new object(), 1);

View File

@ -1,9 +1,6 @@
namespace Ocelot.UnitTests.Infrastructure
{
using Microsoft.AspNetCore.Http;
using System;
using System.Net;
using System.Net.Http;
using Moq;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.RequestData;
@ -11,6 +8,9 @@ namespace Ocelot.UnitTests.Infrastructure
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using Shouldly;
using System;
using System.Net;
using System.Net.Http;
using Xunit;
public class PlaceholdersTests
@ -40,7 +40,7 @@ namespace Ocelot.UnitTests.Infrastructure
[Fact]
public void should_return_remote_ip_address()
{
var httpContext = new DefaultHttpContext(){Connection = { RemoteIpAddress = IPAddress.Any}};
var httpContext = new DefaultHttpContext() { Connection = { RemoteIpAddress = IPAddress.Any } };
_accessor.Setup(x => x.HttpContext).Returns(httpContext);
var result = _placeholders.Get("{RemoteIpAddress}");
result.Data.ShouldBe(httpContext.Connection.RemoteIpAddress.ToString());

View File

@ -1,13 +1,13 @@
using Xunit;
using Shouldly;
using Ocelot.Authorisation;
using Ocelot.Infrastructure.Claims.Parser;
using Moq;
using Ocelot.Authorisation;
using Ocelot.Errors;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Responses;
using Shouldly;
using System.Collections.Generic;
using System.Security.Claims;
using Ocelot.Responses;
using TestStack.BDDfy;
using Ocelot.Errors;
using Xunit;
namespace Ocelot.UnitTests.Infrastructure
{
@ -51,7 +51,7 @@ namespace Ocelot.UnitTests.Infrastructure
var fakeError = new FakeError();
this.Given(_ => GivenTheFollowing(new ClaimsPrincipal()))
.And(_ => GivenTheParserReturns(new ErrorResponse<List<string>>(fakeError)))
.And(_ => GivenTheFollowing(new List<string>(){"doesntmatter"}))
.And(_ => GivenTheFollowing(new List<string>() { "doesntmatter" }))
.When(_ => WhenIAuthorise())
.Then(_ => ThenTheFollowingIsReturned(new ErrorResponse<bool>(fakeError)))
.BDDfy();
@ -61,7 +61,7 @@ namespace Ocelot.UnitTests.Infrastructure
public void should_match_scopes_and_return_ok_result()
{
var claimsPrincipal = new ClaimsPrincipal();
var allowedScopes = new List<string>(){"someScope"};
var allowedScopes = new List<string>() { "someScope" };
this.Given(_ => GivenTheFollowing(claimsPrincipal))
.And(_ => GivenTheParserReturns(new OkResponse<List<string>>(allowedScopes)))
@ -76,8 +76,8 @@ namespace Ocelot.UnitTests.Infrastructure
{
var fakeError = new FakeError();
var claimsPrincipal = new ClaimsPrincipal();
var allowedScopes = new List<string>(){"someScope"};
var userScopes = new List<string>(){"anotherScope"};
var allowedScopes = new List<string>() { "someScope" };
var userScopes = new List<string>() { "anotherScope" };
this.Given(_ => GivenTheFollowing(claimsPrincipal))
.And(_ => GivenTheParserReturns(new OkResponse<List<string>>(userScopes)))
@ -112,12 +112,12 @@ namespace Ocelot.UnitTests.Infrastructure
_result.Data.ShouldBe(expected.Data);
_result.IsError.ShouldBe(expected.IsError);
}
}
public class FakeError : Error
{
public FakeError() : base("fake error", OcelotErrorCode.CannotAddDataError)
{
}
}
public class FakeError : Error
{
public FakeError() : base("fake error", OcelotErrorCode.CannotAddDataError)
{
}
}
}
}

View File

@ -1,6 +1,6 @@
using Xunit;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Infrastructure.Extensions;
using Shouldly;
using Xunit;
namespace Ocelot.UnitTests.Infrastructure
{

View File

@ -76,10 +76,11 @@ namespace Ocelot.UnitTests.Kubernetes
Namespace = "dev"
},
Spec = new ServiceSpecV1()
{
ClusterIP = "localhost"
{
ClusterIP = "localhost"
},
Status = new ServiceStatusV1() {
Status = new ServiceStatusV1()
{
LoadBalancer = new LoadBalancerStatusV1()
}
};
@ -91,7 +92,7 @@ namespace Ocelot.UnitTests.Kubernetes
}
);
this.Given(x => GivenThereIsAFakeKubeServiceDiscoveryProvider(_fakekubeServiceDiscoveryUrl, _serviceName, _namespaces))
this.Given(x => GivenThereIsAFakeKubeServiceDiscoveryProvider(_fakekubeServiceDiscoveryUrl, _serviceName, _namespaces))
.And(x => GivenTheServicesAreRegisteredWithKube(serviceEntryOne))
.When(x => WhenIGetTheServices())
.Then(x => ThenTheCountIs(1))
@ -114,7 +115,6 @@ namespace Ocelot.UnitTests.Kubernetes
_serviceEntries = serviceEntries;
}
private void GivenThereIsAFakeKubeServiceDiscoveryProvider(string url, string serviceName, string namespaces)
{
_fakeKubeBuilder = new WebHostBuilder()

View File

@ -7,7 +7,6 @@ using Ocelot.Provider.Kubernetes;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;
using TestStack.BDDfy;
using Xunit;

View File

@ -7,7 +7,6 @@ using Ocelot.Values;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;
using TestStack.BDDfy;
using Xunit;
@ -59,7 +58,8 @@ namespace Ocelot.UnitTests.Kubernetes
{
_provider = new PollKube(_delay, _factory.Object, _kubeServiceDiscoveryProvider.Object);
var result = Wait.WaitFor(3000).Until(() => {
var result = Wait.WaitFor(3000).Until(() =>
{
try
{
_result = _provider.Get().GetAwaiter().GetResult();

View File

@ -1,20 +1,20 @@
namespace Ocelot.UnitTests.LoadBalancer
{
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Infrastructure;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Ocelot.Values;
using Shouldly;
using Xunit;
using Moq;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System;
using System.Collections;
using Ocelot.Middleware;
using Ocelot.UnitTests.Responder;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Ocelot.Infrastructure;
using Xunit;
public class CookieStickySessionsTests
{

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -42,8 +42,8 @@ namespace Ocelot.UnitTests.LoadBalancer
_leastConnection = new LeastConnection(() => Task.FromResult(_services), serviceName);
var tasks = new Task[100];
for(var i = 0; i < tasks.Length; i++)
for (var i = 0; i < tasks.Length; i++)
{
tasks[i] = LeaseDelayAndRelease();
}
@ -154,7 +154,7 @@ namespace Ocelot.UnitTests.LoadBalancer
[Fact]
public void should_build_connections_per_service()
{
var serviceName = "products";
var serviceName = "products";
var availableServices = new List<Service>
{
@ -185,7 +185,7 @@ namespace Ocelot.UnitTests.LoadBalancer
[Fact]
public void should_release_connection()
{
var serviceName = "products";
var serviceName = "products";
var availableServices = new List<Service>
{
@ -226,11 +226,11 @@ namespace Ocelot.UnitTests.LoadBalancer
var serviceName = "products";
var hostAndPort = new ServiceHostAndPort("localhost", 80);
this.Given(x => x.GivenAHostAndPort(hostAndPort))
.And(x => x.GivenTheLoadBalancerStarts(null, serviceName))
.When(x => x.WhenIGetTheNextHostAndPort())
.Then(x => x.ThenServiceAreNullErrorIsReturned())
.BDDfy();
this.Given(x => x.GivenAHostAndPort(hostAndPort))
.And(x => x.GivenTheLoadBalancerStarts(null, serviceName))
.When(x => x.WhenIGetTheNextHostAndPort())
.Then(x => x.ThenServiceAreNullErrorIsReturned())
.BDDfy();
}
[Fact]
@ -239,11 +239,11 @@ namespace Ocelot.UnitTests.LoadBalancer
var serviceName = "products";
var hostAndPort = new ServiceHostAndPort("localhost", 80);
this.Given(x => x.GivenAHostAndPort(hostAndPort))
.And(x => x.GivenTheLoadBalancerStarts(new List<Service>(), serviceName))
.When(x => x.WhenIGetTheNextHostAndPort())
.Then(x => x.ThenServiceAreEmptyErrorIsReturned())
.BDDfy();
this.Given(x => x.GivenAHostAndPort(hostAndPort))
.And(x => x.GivenTheLoadBalancerStarts(new List<Service>(), serviceName))
.When(x => x.WhenIGetTheNextHostAndPort())
.Then(x => x.ThenServiceAreEmptyErrorIsReturned())
.BDDfy();
}
private void ThenServiceAreNullErrorIsReturned()

View File

@ -2,13 +2,13 @@ using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Responses;
using Ocelot.ServiceDiscovery;
using Ocelot.ServiceDiscovery.Providers;
using Shouldly;
using System.Collections.Generic;
using Ocelot.ServiceDiscovery.Providers;
using TestStack.BDDfy;
using Xunit;
using Ocelot.Responses;
namespace Ocelot.UnitTests.LoadBalancer
{
@ -48,7 +48,7 @@ namespace Ocelot.UnitTests.LoadBalancer
{
var reRoute = new DownstreamReRouteBuilder()
.WithLoadBalancerOptions(new LoadBalancerOptions("RoundRobin", "", 0))
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
this.Given(x => x.GivenAReRoute(reRoute))
@ -64,7 +64,7 @@ namespace Ocelot.UnitTests.LoadBalancer
{
var reRoute = new DownstreamReRouteBuilder()
.WithLoadBalancerOptions(new LoadBalancerOptions("LeastConnection", "", 0))
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
this.Given(x => x.GivenAReRoute(reRoute))
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.LoadBalancer
{
var reRoute = new DownstreamReRouteBuilder()
.WithLoadBalancerOptions(new LoadBalancerOptions("RoundRobin", "", 0))
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
this.Given(x => x.GivenAReRoute(reRoute))
@ -96,7 +96,7 @@ namespace Ocelot.UnitTests.LoadBalancer
{
var reRoute = new DownstreamReRouteBuilder()
.WithLoadBalancerOptions(new LoadBalancerOptions("CookieStickySessions", "", 0))
.WithUpstreamHttpMethod(new List<string> {"Get"})
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
this.Given(x => x.GivenAReRoute(reRoute))

View File

@ -1,6 +1,4 @@
using System;
using System.Threading.Tasks;
using Moq;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.LoadBalancer.LoadBalancers;
@ -8,6 +6,8 @@ using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -26,7 +26,7 @@ namespace Ocelot.UnitTests.LoadBalancer
{
_factory = new Mock<ILoadBalancerFactory>();
_loadBalancerHouse = new LoadBalancerHouse(_factory.Object);
_serviceProviderConfig = new ServiceProviderConfiguration("myType","myHost",123, string.Empty, "configKey", 0);
_serviceProviderConfig = new ServiceProviderConfiguration("myType", "myHost", 123, string.Empty, "configKey", 0);
}
[Fact]
@ -62,7 +62,7 @@ namespace Ocelot.UnitTests.LoadBalancer
.WithLoadBalancerOptions(new LoadBalancerOptions("FakeLoadBalancer", "", 0))
.WithLoadBalancerKey("test")
.Build();
var reRouteTwo = new DownstreamReRouteBuilder()
.WithLoadBalancerOptions(new LoadBalancerOptions("FakeRoundRobinLoadBalancer", "", 0))
.WithLoadBalancerKey("testtwo")
@ -115,7 +115,7 @@ namespace Ocelot.UnitTests.LoadBalancer
_getResult = _loadBalancerHouse.Get(_reRoute, _serviceProviderConfig).Result;
}
private void ThenAnErrorIsReturned()
private void ThenAnErrorIsReturned()
{
_getResult.IsError.ShouldBeTrue();
_getResult.Errors[0].ShouldBeOfType<UnableToFindLoadBalancerError>();
@ -153,7 +153,7 @@ namespace Ocelot.UnitTests.LoadBalancer
_factory.Verify(x => x.Get(_reRoute, _serviceProviderConfig), Times.Once);
}
class FakeLoadBalancer : ILoadBalancer
private class FakeLoadBalancer : ILoadBalancer
{
public Task<Response<ServiceHostAndPort>> Lease(DownstreamContext context)
{
@ -166,7 +166,7 @@ namespace Ocelot.UnitTests.LoadBalancer
}
}
class FakeRoundRobinLoadBalancer : ILoadBalancer
private class FakeRoundRobinLoadBalancer : ILoadBalancer
{
public Task<Response<ServiceHostAndPort>> Lease(DownstreamContext context)
{

View File

@ -2,9 +2,6 @@ using Ocelot.Middleware;
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;
@ -17,6 +14,9 @@ namespace Ocelot.UnitTests.LoadBalancer
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -71,7 +71,7 @@ namespace Ocelot.UnitTests.LoadBalancer
[Fact]
public void should_set_pipeline_error_if_cannot_get_load_balancer()
{
{
var downstreamRoute = new DownstreamReRouteBuilder()
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
@ -94,9 +94,9 @@ namespace Ocelot.UnitTests.LoadBalancer
var downstreamRoute = new DownstreamReRouteBuilder()
.WithUpstreamHttpMethod(new List<string> { "Get" })
.Build();
var serviceProviderConfig = new ServiceProviderConfigurationBuilder()
.Build();
var serviceProviderConfig = new ServiceProviderConfigurationBuilder()
.Build();
this.Given(x => x.GivenTheDownStreamUrlIs("http://my.url/abc?q=123"))
.And(x => GivenTheConfigurationIs(serviceProviderConfig))
@ -130,9 +130,9 @@ namespace Ocelot.UnitTests.LoadBalancer
private void GivenTheLoadBalancerReturnsAnError()
{
_getHostAndPortError = new ErrorResponse<ServiceHostAndPort>(new List<Error>() { new ServicesAreNullError($"services were null for bah") });
_loadBalancer
.Setup(x => x.Lease(It.IsAny<DownstreamContext>()))
.ReturnsAsync(_getHostAndPortError);
_loadBalancer
.Setup(x => x.Lease(It.IsAny<DownstreamContext>()))
.ReturnsAsync(_getHostAndPortError);
}
private void GivenTheLoadBalancerReturns()

View File

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;

View File

@ -1,14 +1,14 @@
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNetCore.Http;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using System.Threading.Tasks;
using Ocelot.Middleware;
using Microsoft.AspNetCore.Http;
namespace Ocelot.UnitTests.LoadBalancer
{

View File

@ -1,16 +1,16 @@
namespace Ocelot.UnitTests.Logging
{
using Moq;
using Xunit;
using Ocelot.Logging;
using Microsoft.Extensions.Logging;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using System;
using Xunit;
public class AspDotNetLoggerTests
{
private readonly Mock<ILogger<object>> _coreLogger;
private readonly AspDotNetLogger _logger;
private readonly AspDotNetLogger _logger;
private Mock<IRequestScopedDataRepository> _repo;
private readonly string _b;
private readonly string _a;
@ -72,7 +72,7 @@ namespace Ocelot.UnitTests.Logging
x => x.Log(
expectedLogLevel,
It.IsAny<EventId>(),
It.Is<object>(o => o.ToString() == expected),
It.Is<object>(o => o.ToString() == expected),
It.IsAny<Exception>(),
It.IsAny<Func<object, Exception, string>>()), Times.Once);
}

View File

@ -1,13 +1,11 @@
using Ocelot.Logging;
using Moq;
using TestStack.BDDfy;
using Butterfly.Client.Tracing;
using Ocelot.Requester;
using Xunit;
using Ocelot.Middleware;
using Microsoft.AspNetCore.Http;
using System;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Logging;
using Ocelot.Middleware;
using System;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Logging
{
@ -63,7 +61,7 @@ namespace Ocelot.UnitTests.Logging
.BDDfy();
}
[Fact]
[Fact]
public void should_trace_middleware_started()
{
this.Given(_ => GivenAMiddlewareName())

View File

@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
using Moq;
using Ocelot.Middleware;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -22,7 +17,7 @@ namespace Ocelot.UnitTests.Middleware
public BaseUrlFinderTests()
{
_data = new List<KeyValuePair<string,string>>();
_data = new List<KeyValuePair<string, string>>();
}
[Fact]
@ -79,4 +74,4 @@ namespace Ocelot.UnitTests.Middleware
_result.ShouldBe(expected);
}
}
}
}

View File

@ -1,11 +1,11 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using Shouldly;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -26,7 +26,7 @@ namespace Ocelot.UnitTests.Middleware
_factory = new Mock<IResponseAggregatorFactory>();
_aggregator = new Mock<IResponseAggregator>();
_context = new DownstreamContext(new DefaultHttpContext());
_pipeline = context => Task.FromResult(_count++);
_pipeline = context => Task.FromResult(_count++);
_factory.Setup(x => x.Get(It.IsAny<ReRoute>())).Returns(_aggregator.Object);
_multiplexer = new Multiplexer(_factory.Object);
}

View File

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Errors;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.UnitTests.Responder;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -66,7 +65,7 @@ namespace Ocelot.UnitTests.Middleware
public class FakeMiddleware : OcelotMiddleware
{
public FakeMiddleware(IOcelotLogger logger)
public FakeMiddleware(IOcelotLogger logger)
: base(logger)
{
}

View File

@ -22,10 +22,10 @@ namespace Ocelot.UnitTests.Middleware
[Fact]
public void should_set_up_pipeline()
{
this.Given(_ => GivenTheDepedenciesAreSetUp())
.When(_ => WhenIBuild())
.Then(_ => ThenThePipelineIsBuilt())
.BDDfy();
this.Given(_ => GivenTheDepedenciesAreSetUp())
.When(_ => WhenIBuild())
.Then(_ => ThenThePipelineIsBuilt())
.BDDfy();
}
[Fact]

View File

@ -3,7 +3,6 @@ using System.Threading.Tasks;
namespace Ocelot.UnitTests.Middleware
{
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.AspNetCore.Http;
@ -14,6 +13,7 @@ namespace Ocelot.UnitTests.Middleware
using Ocelot.Middleware;
using Ocelot.Middleware.Pipeline;
using Shouldly;
using System.Collections.Generic;
using TestStack.BDDfy;
using Xunit;
@ -79,8 +79,6 @@ namespace Ocelot.UnitTests.Middleware
del.Invoke(_downstreamContext);
}
private void ThenTheFuncIsInThePipeline()
{
_counter.ShouldBe(1);
@ -103,7 +101,7 @@ namespace Ocelot.UnitTests.Middleware
private readonly OcelotRequestDelegate _next;
public MultiParametersInvokeMiddleware(OcelotRequestDelegate next)
:base(new FakeLogger())
: base(new FakeLogger())
{
_next = next;
}
@ -115,7 +113,7 @@ namespace Ocelot.UnitTests.Middleware
}
}
class FakeLogger : IOcelotLogger
internal class FakeLogger : IOcelotLogger
{
public void LogCritical(string message, Exception exception)
{

View File

@ -1,12 +1,12 @@
namespace Ocelot.UnitTests.Middleware
{
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Middleware.Multiplexer;
using Shouldly;
using Xunit;
using Ocelot.Configuration;
using TestStack.BDDfy;
using Xunit;
public class ResponseAggregatorFactoryTests
{
@ -21,7 +21,7 @@ namespace Ocelot.UnitTests.Middleware
_aggregator = new SimpleJsonResponseAggregator();
_factory = new InMemoryResponseAggregatorFactory(_provider.Object, _aggregator);
}
[Fact]
public void should_return_simple_json_aggregator()
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using Castle.Components.DictionaryAdapter;
using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
@ -13,6 +8,10 @@ using Ocelot.Middleware.Multiplexer;
using Ocelot.UnitTests.Responder;
using Ocelot.Values;
using Shouldly;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using TestStack.BDDfy;
using Xunit;
@ -81,7 +80,6 @@ namespace Ocelot.UnitTests.Middleware
.BDDfy();
}
[Fact]
public void should_aggregate_n_responses_and_set_response_content_on_upstream_context()
{

View File

@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
@ -13,6 +7,11 @@ using Ocelot.Middleware.Multiplexer;
using Ocelot.Responses;
using Ocelot.UnitTests.Responder;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
@ -71,7 +70,7 @@ namespace Ocelot.UnitTests.Middleware
var contexts = new List<DownstreamContext>
{
new DownstreamContext(new DefaultHttpContext())
{
{
DownstreamResponse = new DownstreamResponse(new StringContent("Tom"), HttpStatusCode.OK, new List<KeyValuePair<string, IEnumerable<string>>>(), "some reason")
},
new DownstreamContext(new DefaultHttpContext())

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<VersionPrefix>0.0.0-dev</VersionPrefix>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyName>Ocelot.UnitTests</AssemblyName>
<PackageId>Ocelot.UnitTests</PackageId>
<OutputType>Exe</OutputType>
@ -36,10 +36,10 @@
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -49,38 +49,41 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.4" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Moq" Version="4.8.3" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
<PackageReference Include="IdentityServer4" Version="2.2.0" />
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.0.1" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
<PackageReference Include="IdentityServer4" Version="2.4.0" />
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.2.0" />
<PackageReference Include="Consul" Version="0.7.2.6" />
<PackageReference Include="CacheManager.Core" Version="1.1.2" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Polly" Version="6.0.1" />
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.2.0" />
<PackageReference Include="Polly" Version="7.1.0" />
<PackageReference Include="Rafty" Version="0.4.4" />
</ItemGroup>
<ItemGroup>
<Folder Include="WebSockets\" />
</ItemGroup>
</Project>
</Project>

View File

@ -1,6 +1,5 @@
namespace Ocelot.UnitTests.Polly
{
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Moq;
@ -10,6 +9,7 @@
using Ocelot.Requester;
using Provider.Polly;
using Shouldly;
using System.IO;
using Xunit;
public class OcelotBuilderExtensionsTests

View File

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -16,4 +15,4 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("54e84f1a-e525-4443-96ec-039cbd50c263")]
[assembly: Guid("54e84f1a-e525-4443-96ec-039cbd50c263")]

View File

@ -1,18 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Moq;
using Moq;
using Ocelot.Configuration;
using Ocelot.Errors;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.QueryStrings;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
using TestStack.BDDfy;
using Xunit;
using System.Net.Http;
using System;
using Ocelot.Request.Middleware;
namespace Ocelot.UnitTests.QueryStrings
{
@ -161,8 +161,8 @@ namespace Ocelot.UnitTests.QueryStrings
_parser
.Setup(
x =>
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
It.IsAny<string>(),
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<int>()))
.Returns(_claimValue);
@ -183,12 +183,12 @@ namespace Ocelot.UnitTests.QueryStrings
_result.IsError.ShouldBe(true);
}
class AnyError : Error
private class AnyError : Error
{
public AnyError()
public AnyError()
: base("blahh", OcelotErrorCode.UnknownError)
{
}
}
}
}
}

View File

@ -2,8 +2,7 @@
namespace Ocelot.UnitTests.QueryStrings
{
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
@ -12,13 +11,14 @@ namespace Ocelot.UnitTests.QueryStrings
using Ocelot.Logging;
using Ocelot.QueryStrings;
using Ocelot.QueryStrings.Middleware;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using TestStack.BDDfy;
using Xunit;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Ocelot.Request.Middleware;
public class ClaimsToQueryStringMiddlewareTests
{

Some files were not shown because too many files have changed in this diff Show More