Ocelot/test/Ocelot.UnitTests/Middleware/OcelotPipelineExtensionsTests.cs
Tom Pallister 4f061f2b74
Feature/steeltoe (#324)
* #262 - Integrated Steeltoe Service Discovery with Ocelot for review.

* messing around

* seems to be working with eureka

* acceptance test passing with external lib references

* #262 support for netflix eureka service discovery thanks to pivotal

* #262 fixed warnings
2018-04-20 21:28:49 +01:00

50 lines
1.5 KiB
C#

namespace Ocelot.UnitTests.Middleware
{
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Middleware.Pipeline;
using Pivotal.Discovery.Client;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class OcelotPipelineExtensionsTests
{
private OcelotPipelineBuilder _builder;
private OcelotRequestDelegate _handlers;
[Fact]
public void should_set_up_pipeline()
{
this.Given(_ => GivenTheDepedenciesAreSetUp())
.When(_ => WhenIBuild())
.Then(_ => ThenThePipelineIsBuilt())
.BDDfy();
}
private void ThenThePipelineIsBuilt()
{
_handlers.ShouldNotBeNull();
}
private void WhenIBuild()
{
_handlers = _builder.BuildOcelotPipeline(new OcelotPipelineConfiguration());
}
private void GivenTheDepedenciesAreSetUp()
{
IConfigurationBuilder test = new ConfigurationBuilder();
var root = test.Build();
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>(root);
services.AddDiscoveryClient(new DiscoveryOptions {ClientType = DiscoveryClientType.EUREKA});
services.AddOcelot();
var provider = services.BuildServiceProvider();
_builder = new OcelotPipelineBuilder(provider);
}
}
}