mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-20 04:58:15 +08:00
#296 started writing merge code
This commit is contained in:
@ -6,6 +6,11 @@ using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.DependencyInjection
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Ocelot.Configuration.File;
|
||||
|
||||
public class ConfigurationBuilderExtensionsTests
|
||||
{
|
||||
private IConfigurationRoot _configuration;
|
||||
@ -20,6 +25,61 @@ namespace Ocelot.UnitTests.DependencyInjection
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_merge_files()
|
||||
{
|
||||
var globalConfig = new FileConfiguration
|
||||
{
|
||||
GlobalConfiguration = new FileGlobalConfiguration
|
||||
{
|
||||
BaseUrl = "BaseUrl",
|
||||
RateLimitOptions = new FileRateLimitOptions
|
||||
{
|
||||
HttpStatusCode = 500,
|
||||
ClientIdHeader = "ClientIdHeader",
|
||||
DisableRateLimitHeaders = true,
|
||||
QuotaExceededMessage = "QuotaExceededMessage",
|
||||
RateLimitCounterPrefix = "RateLimitCounterPrefix"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var reRoute = new FileConfiguration
|
||||
{
|
||||
ReRoutes = new List<FileReRoute>
|
||||
{
|
||||
new FileReRoute
|
||||
{
|
||||
DownstreamScheme = "DownstreamScheme",
|
||||
Key = "Key",
|
||||
UpstreamHost = "UpstreamHost",
|
||||
UpstreamHttpMethod = new List<string>
|
||||
{
|
||||
"UpstreamHttpMethod"
|
||||
},
|
||||
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||
{
|
||||
new FileHostAndPort
|
||||
{
|
||||
Host = "Host",
|
||||
Port = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var globalJson = JsonConvert.SerializeObject(globalConfig);
|
||||
//File.WriteAllText("ocelot.global.json", globalJson);
|
||||
|
||||
var reRouteJson = JsonConvert.SerializeObject(reRoute);
|
||||
//File.WriteAllText("ocelot.reRoute.json", reRouteJson);
|
||||
|
||||
IConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
//builder.AddOcelot();
|
||||
|
||||
}
|
||||
|
||||
private void GivenTheBaseUrl(string baseUrl)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
|
Reference in New Issue
Block a user