mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-29 05:42:51 +08:00

* test for issue * added service fabric sample * working!! * changed sample naming to Ocelot * removed files we dont need * removed files we dont need * updated sample gitignore * updated sample gitignore * getting ocelot to work with service fabric using the reverse proxy * #238 - added support for service fabric discovery provider, proxies requests through naming service, wont work on partioned service fabric services yet * #238 - Manually tested service fabric using sample..all seems OK. Made some changes after testing, added docs * #238 - added docs for servic fabric
73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using Ocelot.Configuration;
|
|
using Ocelot.Configuration.Builder;
|
|
using Ocelot.Configuration.Creator;
|
|
using Ocelot.Configuration.File;
|
|
using Shouldly;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
namespace Ocelot.UnitTests.Configuration
|
|
{
|
|
public class ServiceProviderCreatorTests
|
|
{
|
|
private ServiceProviderConfigurationCreator _creator;
|
|
private FileReRoute _reRoute;
|
|
private FileGlobalConfiguration _globalConfig;
|
|
private ServiceProviderConfiguration _result;
|
|
|
|
public ServiceProviderCreatorTests()
|
|
{
|
|
_creator = new ServiceProviderConfigurationCreator();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_create_service_provider_config()
|
|
{
|
|
var reRoute = new FileReRoute();
|
|
|
|
var globalConfig = new FileGlobalConfiguration
|
|
{
|
|
ServiceDiscoveryProvider = new FileServiceDiscoveryProvider
|
|
{
|
|
Host = "127.0.0.1",
|
|
Port = 1234,
|
|
Type = "ServiceFabric"
|
|
}
|
|
};
|
|
|
|
var expected = new ServiceProviderConfigurationBuilder()
|
|
.WithServiceDiscoveryProviderHost("127.0.0.1")
|
|
.WithServiceDiscoveryProviderPort(1234)
|
|
.WithServiceDiscoveryProviderType("ServiceFabric")
|
|
.Build();
|
|
|
|
this.Given(x => x.GivenTheFollowingReRoute(reRoute))
|
|
.And(x => x.GivenTheFollowingGlobalConfig(globalConfig))
|
|
.When(x => x.WhenICreate())
|
|
.Then(x => x.ThenTheConfigIs(expected))
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenTheFollowingReRoute(FileReRoute fileReRoute)
|
|
{
|
|
_reRoute = fileReRoute;
|
|
}
|
|
|
|
private void GivenTheFollowingGlobalConfig(FileGlobalConfiguration fileGlobalConfig)
|
|
{
|
|
_globalConfig = fileGlobalConfig;
|
|
}
|
|
|
|
private void WhenICreate()
|
|
{
|
|
_result = _creator.Create(_globalConfig);
|
|
}
|
|
|
|
private void ThenTheConfigIs(ServiceProviderConfiguration expected)
|
|
{
|
|
_result.Host.ShouldBe(expected.Host);
|
|
_result.Port.ShouldBe(expected.Port);
|
|
}
|
|
}
|
|
}
|