Ocelot/test/Ocelot.UnitTests/Eureka/EurekaMiddlewareConfigurationProviderTests.cs
Tom Pallister 11a2d13f18
Feat/monorepo (#734)
* 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
2019-01-07 19:52:53 +00:00

48 lines
2.0 KiB
C#

namespace Ocelot.UnitTests.Eureka
{
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Repository;
using Provider.Eureka;
using Responses;
using Shouldly;
using Steeltoe.Common.Discovery;
using Xunit;
public class EurekaMiddlewareConfigurationProviderTests
{
[Fact]
public void should_not_build()
{
var configRepo = new Mock<IInternalConfigurationRepository>();
configRepo.Setup(x => x.Get())
.Returns(new OkResponse<IInternalConfiguration>(new InternalConfiguration(null, null, null, null, null, null, null, null)));
var services = new ServiceCollection();
services.AddSingleton<IInternalConfigurationRepository>(configRepo.Object);
var sp = services.BuildServiceProvider();
var provider = EurekaMiddlewareConfigurationProvider.Get(new ApplicationBuilder(sp));
provider.ShouldBeOfType<Task>();
}
[Fact]
public void should_build()
{
var serviceProviderConfig = new ServiceProviderConfigurationBuilder().WithType("eureka").Build();
var client = new Mock<IDiscoveryClient>();
var configRepo = new Mock<IInternalConfigurationRepository>();
configRepo.Setup(x => x.Get())
.Returns(new OkResponse<IInternalConfiguration>(new InternalConfiguration(null, null, serviceProviderConfig, null, null, null, null, null)));
var services = new ServiceCollection();
services.AddSingleton<IInternalConfigurationRepository>(configRepo.Object);
services.AddSingleton<IDiscoveryClient>(client.Object);
var sp = services.BuildServiceProvider();
var provider = EurekaMiddlewareConfigurationProvider.Get(new ApplicationBuilder(sp));
provider.ShouldBeOfType<Task>();
}
}
}