mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 14:08:15 +08:00
Added the possibility to manage the placeholders from outside ocelot (#724)
This commit is contained in:

committed by
Brian Delgado

parent
9bbb6364f2
commit
35253025c7
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user