Merge remote-tracking branch 'upstream/release-3.1.8' into feature/AddStyleCopAnalyzers

# Conflicts:
#	src/Ocelot/Configuration/ServiceProviderConfiguration.cs
This commit is contained in:
Philip Wood
2018-03-03 16:28:19 +00:00
70 changed files with 2373 additions and 481 deletions

View File

@ -0,0 +1,58 @@
namespace Ocelot.UnitTests.ServiceDiscovery
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Consul;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Moq;
using Ocelot.Logging;
using Ocelot.ServiceDiscovery;
using Ocelot.Values;
using Xunit;
using TestStack.BDDfy;
using Shouldly;
public class ServiceFabricServiceDiscoveryProviderTests
{
private ServiceFabricServiceDiscoveryProvider _provider;
private ServiceFabricConfiguration _config;
private string _host;
private string _serviceName;
private int _port;
private List<Service> _services;
[Fact]
public void should_return_service_fabric_naming_service()
{
this.Given(x => GivenTheFollowing())
.When(x => WhenIGet())
.Then(x => ThenTheServiceFabricNamingServiceIsRetured())
.BDDfy();
}
private void GivenTheFollowing()
{
_host = "localhost";
_serviceName = "OcelotServiceApplication/OcelotApplicationService";
_port = 19081;
}
private void WhenIGet()
{
_config = new ServiceFabricConfiguration(_host, _port, _serviceName);
_provider = new ServiceFabricServiceDiscoveryProvider(_config);
_services = _provider.Get().GetAwaiter().GetResult();
}
private void ThenTheServiceFabricNamingServiceIsRetured()
{
_services.Count.ShouldBe(1);
_services[0].HostAndPort.DownstreamHost.ShouldBe(_host);
_services[0].HostAndPort.DownstreamPort.ShouldBe(_port);
}
}
}

View File

@ -77,6 +77,24 @@ namespace Ocelot.UnitTests.ServiceDiscovery
.BDDfy();
}
[Fact]
public void should_return_service_fabric_provider()
{
var reRoute = new DownstreamReRouteBuilder()
.WithServiceName("product")
.WithUseServiceDiscovery(true)
.Build();
var serviceConfig = new ServiceProviderConfigurationBuilder()
.WithServiceDiscoveryProviderType("ServiceFabric")
.Build();
this.Given(x => x.GivenTheReRoute(serviceConfig, reRoute))
.When(x => x.WhenIGetTheServiceProvider())
.Then(x => x.ThenTheServiceProviderIs<ServiceFabricServiceDiscoveryProvider>())
.BDDfy();
}
private void ThenTheFollowingServicesAreReturned(List<DownstreamHostAndPort> downstreamAddresses)
{
var result = (ConfigurationServiceProvider)_result;