mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 09:08:14 +08:00
some tidying up and a bit of refactoring...not too happy about how the proxy is working at the moment! May need a rethink!
This commit is contained in:
@ -58,6 +58,7 @@ namespace Ocelot.UnitTests
|
||||
}))
|
||||
.When(x => x.WhenIValidateTheConfiguration())
|
||||
.Then(x => x.ThenTheResultIsNotValid())
|
||||
.And(x => x.ThenTheErrorIs<DownstreamTemplateAlreadyUsedError>())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
@ -73,12 +74,17 @@ namespace Ocelot.UnitTests
|
||||
|
||||
private void ThenTheResultIsValid()
|
||||
{
|
||||
_result.IsError.ShouldBeFalse();
|
||||
_result.Data.IsError.ShouldBeFalse();
|
||||
}
|
||||
|
||||
private void ThenTheResultIsNotValid()
|
||||
{
|
||||
_result.IsError.ShouldBeTrue();
|
||||
_result.Data.IsError.ShouldBeTrue();
|
||||
}
|
||||
|
||||
private void ThenTheErrorIs<T>()
|
||||
{
|
||||
_result.Data.Errors[0].ShouldBeOfType<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,21 @@ namespace Ocelot.UnitTests
|
||||
[Fact]
|
||||
public void should_return_route()
|
||||
{
|
||||
this.Given(x => x.GivenThereIsAnUpstreamUrlPath("somePath"))
|
||||
this.Given(x => x.GivenThereIsAnUpstreamUrlPath("someUpstreamPath"))
|
||||
.And(x => x.GivenTheConfigurationIs(new Configuration {
|
||||
ReRoutes = new List<ReRoute>
|
||||
{
|
||||
new ReRoute()
|
||||
{
|
||||
UpstreamTemplate = "somePath",
|
||||
DownstreamTemplate = "somPath"
|
||||
UpstreamTemplate = "someUpstreamPath",
|
||||
DownstreamTemplate = "someDownstreamPath"
|
||||
}
|
||||
}
|
||||
}))
|
||||
.And(x => x.GivenTheUrlMatcherReturns(new UrlMatch(true, new List<TemplateVariableNameAndValue>(), "somePath")))
|
||||
.And(x => x.GivenTheUrlMatcherReturns(new UrlMatch(true, new List<TemplateVariableNameAndValue>(), "someDownstreamPath")))
|
||||
.When(x => x.WhenICallTheFinder())
|
||||
.Then(
|
||||
x => x.ThenTheFollowingIsReturned(new DownstreamRoute(new List<TemplateVariableNameAndValue>(), "somePath")))
|
||||
x => x.ThenTheFollowingIsReturned(new DownstreamRoute(new List<TemplateVariableNameAndValue>(), "someDownstreamPath")))
|
||||
.And(x => x.ThenTheUrlMatcherIsCalledCorrectly())
|
||||
.BDDfy();
|
||||
}
|
||||
@ -117,6 +117,7 @@ namespace Ocelot.UnitTests
|
||||
private void ThenTheFollowingIsReturned(DownstreamRoute expected)
|
||||
{
|
||||
_result.Data.DownstreamUrlTemplate.ShouldBe(expected.DownstreamUrlTemplate);
|
||||
|
||||
for (int i = 0; i < _result.Data.TemplateVariableNameAndValues.Count; i++)
|
||||
{
|
||||
_result.Data.TemplateVariableNameAndValues[i].TemplateVariableName.ShouldBe(
|
||||
|
@ -131,7 +131,7 @@ namespace Ocelot.UnitTests
|
||||
|
||||
private void WhenIReplaceTheTemplateVariables()
|
||||
{
|
||||
_result = _downstreamUrlPathReplacer.ReplaceTemplateVariable(_downstreamRoute);
|
||||
_result = _downstreamUrlPathReplacer.ReplaceTemplateVariables(_downstreamRoute);
|
||||
}
|
||||
|
||||
private void ThenTheDownstreamUrlPathIsReturned(string expected)
|
||||
|
Reference in New Issue
Block a user