mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 03:18:15 +08:00
hacking yaml config
This commit is contained in:
54
test/Ocelot.AcceptanceTests/ConfigurationReaderTests.cs
Normal file
54
test/Ocelot.AcceptanceTests/ConfigurationReaderTests.cs
Normal file
@ -0,0 +1,54 @@
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Library.Infrastructure.Configuration;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
public class ConfigurationReaderTests
|
||||
{
|
||||
private readonly IConfigurationReader _configurationReader;
|
||||
private string _configPath;
|
||||
private Configuration _result;
|
||||
|
||||
public ConfigurationReaderTests()
|
||||
{
|
||||
_configurationReader = new ConfigurationReader();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void can_read_configuration()
|
||||
{
|
||||
const string path = "./ConfigurationReaderTests.can_read_configuration.yaml";
|
||||
|
||||
var expected =
|
||||
new Configuration(new List<Route>
|
||||
{
|
||||
new Route("productservice/category/{categoryId}/products/{productId}/variants/{variantId}",
|
||||
"https://www.moonpig.com/api/products/{categoryId}/{productId}/{variantId}")
|
||||
});
|
||||
|
||||
this.Given(x => x.GivenAConfigPathOf(path))
|
||||
.When(x => x.WhenICallTheConfigurationReader())
|
||||
.Then(x => x.ThenTheFollowingConfigurationIsReturned(expected))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenAConfigPathOf(string configPath)
|
||||
{
|
||||
_configPath = configPath;
|
||||
}
|
||||
|
||||
private void WhenICallTheConfigurationReader()
|
||||
{
|
||||
_result = _configurationReader.Read(_configPath);
|
||||
}
|
||||
|
||||
private void ThenTheFollowingConfigurationIsReturned(Configuration expected)
|
||||
{
|
||||
_result.Routes[0].Downstream.ShouldBe(expected.Routes[0].Downstream);
|
||||
_result.Routes[0].Upstream.ShouldBe(expected.Routes[0].Upstream);
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact]
|
||||
public void should_return_response_200()
|
||||
{
|
||||
this.When(x => x.WhenIRequestTheUrl("/"))
|
||||
|
3
test/Ocelot.AcceptanceTests/configuration.yaml
Normal file
3
test/Ocelot.AcceptanceTests/configuration.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
routes:
|
||||
- downstream: "productservice/category/{categoryId}/products/{productId}/variants/{variantId}"
|
||||
upstream: "https://www.moonpig.com/api/products/{categoryId}/{productId}/{variantId}"
|
@ -1,39 +1,48 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"testRunner": "xunit",
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"version": "1.0.0",
|
||||
"type": "platform"
|
||||
},
|
||||
"Microsoft.AspNetCore.Mvc": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "1.0.0",
|
||||
"Microsoft.Extensions.Logging": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.AspNetCore.Http": "1.0.0",
|
||||
"Ocelot.Library": "1.0.0-*",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||
"Shouldly": "2.8.0",
|
||||
"Ocelot": "1.0.0-*",
|
||||
"Microsoft.AspNetCore.TestHost": "1.0.0",
|
||||
"TestStack.BDDfy": "4.3.1"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"dotnet5.6",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
"buildOptions": {
|
||||
"copyToOutput": {
|
||||
"include": [
|
||||
"configuration.yaml"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"testRunner": "xunit",
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"version": "1.0.0",
|
||||
"type": "platform"
|
||||
},
|
||||
"Microsoft.AspNetCore.Mvc": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "1.0.0",
|
||||
"Microsoft.Extensions.Logging": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.AspNetCore.Http": "1.0.0",
|
||||
"Ocelot.Library": "1.0.0-*",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||
"Shouldly": "2.8.0",
|
||||
"Ocelot": "1.0.0-*",
|
||||
"Microsoft.AspNetCore.TestHost": "1.0.0",
|
||||
"TestStack.BDDfy": "4.3.1",
|
||||
"YamlDotNet": "3.9.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"dotnet5.6",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,28 +3,29 @@
|
||||
|
||||
"testRunner": "xunit",
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"version": "1.0.0",
|
||||
"type": "platform"
|
||||
},
|
||||
"Microsoft.AspNetCore.Mvc": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "1.0.0",
|
||||
"Microsoft.Extensions.Logging": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.AspNetCore.Http": "1.0.0",
|
||||
"Ocelot.Library": "1.0.0-*",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||
"Shouldly": "2.8.0",
|
||||
"TestStack.BDDfy": "4.3.1"
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"version": "1.0.0",
|
||||
"type": "platform"
|
||||
},
|
||||
"Microsoft.AspNetCore.Mvc": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
|
||||
"Microsoft.Extensions.Configuration.Json": "1.0.0",
|
||||
"Microsoft.Extensions.Logging": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0",
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.AspNetCore.Http": "1.0.0",
|
||||
"Ocelot.Library": "1.0.0-*",
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||
"Shouldly": "2.8.0",
|
||||
"TestStack.BDDfy": "4.3.1",
|
||||
"YamlDotNet": "3.9.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
|
Reference in New Issue
Block a user