Added the possibility to manage the placeholders from outside ocelot (#724)

This commit is contained in:
Ronald van Helden
2019-01-03 14:55:23 +01:00
committed by Brian Delgado
parent 9bbb6364f2
commit 35253025c7
7 changed files with 86 additions and 3 deletions

View File

@ -91,5 +91,37 @@ namespace Ocelot.UnitTests.Infrastructure
var result = _placeholders.Get("{TraceId}");
result.Data.ShouldBe(traceId);
}
[Fact]
public void should_return_ok_when_added()
{
var result = _placeholders.Add("{Test}", () => new OkResponse<string>("test"));
result.IsError.ShouldBeFalse();
}
[Fact]
public void should_return_ok_when_removed()
{
var result = _placeholders.Add("{Test}", () => new OkResponse<string>("test"));
result = _placeholders.Remove("{Test}");
result.IsError.ShouldBeFalse();
}
[Fact]
public void should_return_error_when_added()
{
var result = _placeholders.Add("{Test}", () => new OkResponse<string>("test"));
result = _placeholders.Add("{Test}", () => new OkResponse<string>("test"));
result.IsError.ShouldBeTrue();
result.Errors[0].Message.ShouldBe("Unable to add placeholder: {Test}, placeholder already exists");
}
[Fact]
public void should_return_error_when_removed()
{
var result = _placeholders.Remove("{Test}");
result.IsError.ShouldBeTrue();
result.Errors[0].Message.ShouldBe("Unable to remove placeholder: {Test}, placeholder does not exists");
}
}
}

View File

@ -125,7 +125,7 @@ namespace Ocelot.UnitTests.Responder
// If this test fails then it's because the number of error codes has changed.
// You should make the appropriate changes to the test cases here to ensure
// they cover all the error codes, and then modify this assertion.
Enum.GetNames(typeof(OcelotErrorCode)).Length.ShouldBe(34, "Looks like the number of error codes has changed. Do you need to modify ErrorsToHttpStatusCodeMapper?");
Enum.GetNames(typeof(OcelotErrorCode)).Length.ShouldBe(36, "Looks like the number of error codes has changed. Do you need to modify ErrorsToHttpStatusCodeMapper?");
}
private void ShouldMapErrorToStatusCode(OcelotErrorCode errorCode, HttpStatusCode expectedHttpStatusCode)