Ocelot/test/Ocelot.UnitTests/DependencyInjection/ServiceCollectionExtensionTests.cs
Tom Pallister 68242102d8
Feature/hacking consul file config (#157)
* moving things around to see if I can get consul to store fileconfiguration rather than ocelotconfiguration

* more refactoring to see if we can get a test for the feature

* acceptance test passing for updating in consul..need to sort object comparison out

* fixed the failing tests
2017-11-17 17:58:39 +00:00

48 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.DependencyInjection
{
public class ServiceCollectionExtensionTests
{
private Exception _ex;
[Fact]
public void should_set_up_services()
{
this.When(x => WhenISetUpOcelotServices())
.Then(x => ThenAnExceptionIsntThrown())
.BDDfy();
}
private void WhenISetUpOcelotServices()
{
try
{
IWebHostBuilder builder = new WebHostBuilder();
IConfigurationRoot configRoot = new ConfigurationRoot(new List<IConfigurationProvider>());
IServiceCollection services = new ServiceCollection();
services.AddSingleton(builder);
services.AddOcelot(configRoot);
}
catch (Exception e)
{
_ex = e;
}
}
private void ThenAnExceptionIsntThrown()
{
_ex.ShouldBeNull();
}
}
}