namespace Ocelot.UnitTests.Consul { using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; using Provider.Consul; using Shouldly; using TestStack.BDDfy; using Xunit; public class OcelotBuilderExtensionsTests { private readonly IServiceCollection _services; private IServiceProvider _serviceProvider; private readonly IConfiguration _configRoot; private IOcelotBuilder _ocelotBuilder; private Exception _ex; public OcelotBuilderExtensionsTests() { _configRoot = new ConfigurationRoot(new List()); _services = new ServiceCollection(); _services.AddSingleton(); _services.AddSingleton(_configRoot); } [Fact] public void should_set_up_consul() { this.Given(x => WhenISetUpOcelotServices()) .When(x => WhenISetUpConsul()) .Then(x => ThenAnExceptionIsntThrown()) .BDDfy(); } private void WhenISetUpOcelotServices() { try { _ocelotBuilder = _services.AddOcelot(_configRoot); } catch (Exception e) { _ex = e; } } private void WhenISetUpConsul() { try { _ocelotBuilder.AddConsul().AddConfigStoredInConsul(); } catch (Exception e) { _ex = e; } } private void ThenAnExceptionIsntThrown() { _ex.ShouldBeNull(); } } }