This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0604569
commit 8f05ec0
Showing
5 changed files
with
103 additions
and
22 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
test/Ocelot.Provider.Eureka.UnitTests/EurekaMiddlewareConfigurationProviderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Ocelot.Provider.Eureka.UnitTests | ||
{ | ||
using System.Threading.Tasks; | ||
using Configuration; | ||
using Configuration.Builder; | ||
using Configuration.Repository; | ||
using Microsoft.AspNetCore.Builder.Internal; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
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>(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
test/Ocelot.Provider.Eureka.UnitTests/EurekaProviderFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Ocelot.Provider.Eureka.UnitTests | ||
{ | ||
using Configuration.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
using Shouldly; | ||
using Steeltoe.Common.Discovery; | ||
using Xunit; | ||
|
||
public class EurekaProviderFactoryTests | ||
{ | ||
[Fact] | ||
public void should_not_get() | ||
{ | ||
var config = new ServiceProviderConfigurationBuilder().Build(); | ||
var sp = new ServiceCollection().BuildServiceProvider(); | ||
var provider = EurekaProviderFactory.Get(sp, config, null); | ||
provider.ShouldBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void should_get() | ||
{ | ||
var config = new ServiceProviderConfigurationBuilder().WithType("eureka").Build(); | ||
var client = new Mock<IDiscoveryClient>(); | ||
var services = new ServiceCollection(); | ||
services.AddSingleton<IDiscoveryClient>(client.Object); | ||
var sp = services.BuildServiceProvider(); | ||
var provider = EurekaProviderFactory.Get(sp, config, null); | ||
provider.ShouldBeOfType<EurekaServiceDiscoveryProvider>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": true, | ||
"LogLevel": { | ||
"Default": "Error", | ||
"System": "Error", | ||
"Microsoft": "Error" | ||
} | ||
}, | ||
"spring": { | ||
"application": { | ||
"name": "ocelot" | ||
} | ||
}, | ||
"eureka": { | ||
"client": { | ||
"serviceUrl": "http://localhost:8761/eureka/", | ||
"shouldRegisterWithEureka": true, | ||
"shouldFetchRegistry": true, | ||
"port": 5000, | ||
"hostName": "localhost" | ||
} | ||
} | ||
} |