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

* squash SA1649 warnings (file/type name mismatch) * squash SA1127 warnings (generic constraint on own line) * squash SA1507 warnings (multiple blank lines) * squash package analysis warnings re: summary text It's not actually possible to provide a summary right now as per https://github.com/NuGet/Home/issues/4587 * squash missing castle.core reference warning * squash obsolete method warnings re: AddOcelotBaseUrl
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Ocelot.DependencyInjection;
|
|
using Shouldly;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
namespace Ocelot.UnitTests.DependencyInjection
|
|
{
|
|
public class ConfigurationBuilderExtensionsTests
|
|
{
|
|
private IConfigurationRoot _configuration;
|
|
private string _result;
|
|
|
|
[Fact]
|
|
public void should_add_base_url_to_config()
|
|
{
|
|
this.Given(x => GivenTheBaseUrl("test"))
|
|
.When(x => WhenIGet("BaseUrl"))
|
|
.Then(x => ThenTheResultIs("test"))
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenTheBaseUrl(string baseUrl)
|
|
{
|
|
#pragma warning disable CS0618
|
|
var builder = new ConfigurationBuilder()
|
|
.AddOcelotBaseUrl(baseUrl);
|
|
#pragma warning restore CS0618
|
|
_configuration = builder.Build();
|
|
}
|
|
|
|
private void WhenIGet(string key)
|
|
{
|
|
_result = _configuration.GetValue("BaseUrl", "");
|
|
}
|
|
|
|
private void ThenTheResultIs(string expected)
|
|
{
|
|
_result.ShouldBe(expected);
|
|
}
|
|
}
|
|
}
|