mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-10-31 21:15:28 +08:00 
			
		
		
		
	 11a2d13f18
			
		
	
	11a2d13f18
	
	
	
		
			
			* copied everything from repos back to ocelot repo * added src projects to sln * removed all test projects that have no tests * added all test projects to sln * removed test not on master * merged unit tests * merged acceptance tests * merged integration tests * fixed namepaces * build script creates packages for all projects * updated docs to make sure no references to external repos that we will remove * +semver: breaking
		
			
				
	
	
		
			70 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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<IConfigurationProvider>());
 | |
|             _services = new ServiceCollection();
 | |
|             _services.AddSingleton<IHostingEnvironment, HostingEnvironment>();
 | |
|             _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();
 | |
|         }
 | |
|     }
 | |
| }
 |