Permalink
Browse files

Added test to ensure NancyEngine doesn't throw an exception when sett…

…ing Nancy-Version and the header already exists
  • Loading branch information...
1 parent 80cb786 commit b0a3b1f59f5d984ea6c06349f45c1e621fd86c56 @thecodejunkie thecodejunkie committed Mar 13, 2011
Showing with 21 additions and 0 deletions.
  1. +21 −0 src/Nancy.Tests/Unit/NancyEngineFixture.cs
@@ -122,6 +122,27 @@ public void Should_add_nancy_version_number_header_on_returned_response()
}
[Fact]
+ public void Should_not_throw_exception_when_setting_nancy_version_header_and_it_already_existed()
+ {
+ // Given
+ var cachedResponse = new Response();
+ cachedResponse.Headers.Add("Nancy-Version", "1.2.3.4");
+ Func<NancyContext, Response> preRequestHook = (ctx) => cachedResponse;
+
+ var prePostResolver = A.Fake<IRouteResolver>();
+ A.CallTo(() => prePostResolver.Resolve(A<NancyContext>.Ignored, A<IRouteCache>.Ignored.Argument)).Returns(new ResolveResult(route, DynamicDictionary.Empty, preRequestHook, null));
+
+ var localEngine = new NancyEngine(prePostResolver, A.Fake<IRouteCache>(), contextFactory);
+ var request = new Request("GET", "/", "http");
+
+ // When
+ var exception = Record.Exception(() => localEngine.HandleRequest(request));
+
+ // Then
+ exception.ShouldBeNull();
+ }
+
+ [Fact]
public void Should_set_nancy_version_number_on_returned_response()
{
// Given

0 comments on commit b0a3b1f

Please sign in to comment.