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

* feat: update to asp.net core 3.0 preview 9 * fix : AspDotNetLogger unittest * feat: update generic host and useMvc 1、Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing https://github.com/aspnet/AspNetCore/issues/9542 2、 use IHost and IHostBuilder * feat : update .net core 3.0 rc1 * eureka extension * fixed logger formatter error * fixed synchronous operations are disallowed of ReadToEnd method * fix log tests * Flush method of FakeStream should do nothing * Update ContentTests.cs * Fixed ws tests * feat: delelte comment code * feat: update .net core 3.0 RTM * Update OcelotBuilderTests.cs * Update .travis.yml mono 6.0.0 and dotnet 3.0.100 * Update Ocelot.IntegrationTests.csproj update Microsoft.Data.SQLite 3.0.0 * Update .travis.yml * feat: remove FrameworkReference 1、 remove FrameworkReference 2、 update package * add appveyor configuration to use version of VS2019 with dotnet core 3 sdk support * update obsoleted SetCollectionValidator method * Swap out OpenCover for Coverlet * Bump Cake to 0.35.0 * Downgrade coveralls.net to 0.7.0 Fix disposing of PollConsul instance * Remove environment specific path separator * Do not return ReportGenerator on Mac/Linux * Remove direct dependency on IInternalConfiguration * Fix ordering of variable assignment * Fix broken tests * Fix acceptance tests for Consul
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using Ocelot.Configuration.Builder;
|
|
|
|
namespace Ocelot.UnitTests.Consul
|
|
{
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Moq;
|
|
using Ocelot.Configuration;
|
|
using Ocelot.Logging;
|
|
using Provider.Consul;
|
|
using Shouldly;
|
|
using System;
|
|
using Xunit;
|
|
|
|
public class ProviderFactoryTests
|
|
{
|
|
private readonly IServiceProvider _provider;
|
|
|
|
public ProviderFactoryTests()
|
|
{
|
|
var services = new ServiceCollection();
|
|
var loggerFactory = new Mock<IOcelotLoggerFactory>();
|
|
var logger = new Mock<IOcelotLogger>();
|
|
loggerFactory.Setup(x => x.CreateLogger<Consul>()).Returns(logger.Object);
|
|
loggerFactory.Setup(x => x.CreateLogger<PollConsul>()).Returns(logger.Object);
|
|
var consulFactory = new Mock<IConsulClientFactory>();
|
|
services.AddSingleton<IConsulClientFactory>(consulFactory.Object);
|
|
services.AddSingleton<IOcelotLoggerFactory>(loggerFactory.Object);
|
|
_provider = services.BuildServiceProvider();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_return_ConsulServiceDiscoveryProvider()
|
|
{
|
|
var reRoute = new DownstreamReRouteBuilder()
|
|
.WithServiceName("")
|
|
.Build();
|
|
|
|
var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("", "", 1, "", "", 1), reRoute);
|
|
provider.ShouldBeOfType<Consul>();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_return_PollingConsulServiceDiscoveryProvider()
|
|
{
|
|
var stopsPollerFromPolling = 10000;
|
|
|
|
var reRoute = new DownstreamReRouteBuilder()
|
|
.WithServiceName("")
|
|
.Build();
|
|
|
|
var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("pollconsul", "", 1, "", "", stopsPollerFromPolling), reRoute);
|
|
var pollProvider = provider as PollConsul;
|
|
pollProvider.ShouldNotBeNull();
|
|
pollProvider.Dispose();
|
|
}
|
|
}
|
|
}
|