Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContentNegotiationFixture
- {
- private readonly INancyBootstrapper bootstrapper;
- private readonly Browser browser;
- public ContentNegotiationFixture()
- {
- var module = new ConfigurableNancyModule(with =>{
- with.Get("/int", x => 200);
- with.Get("/string", x => "hello");
- with.Get("/httpstatuscode", x => HttpStatusCode.Accepted);
- with.Get("/action", x => {
- Action<Stream> result = stream =>{
- var wrapper = new UnclosableStreamWrapper(stream);
- using (var writer = new StreamWriter(wrapper))
- {
- writer.Write("Hiya Nancy!");
- }
- };
- return result;
- });
- });
- this.bootstrapper = new ConfigurableBootstrapper(with => {
- with.Module(module);
- });
- this.browser = new Browser(this.bootstrapper);
- }
- [Fact]
- public void Should_return_int_value_from_get_route_as_response_with_status_code_set_to_value()
- {
- // Given
- // When
- var response = this.browser.Get("/int");
- // Then
- Assert.Equal((HttpStatusCode)200, response.StatusCode);
- }
- [Fact]
- public void Should_return_string_value_from_get_route_as_response_with_content_set_as_value()
- {
- // Given
- // When
- var response = this.browser.Get("/string");
- // Then
- Assert.Equal("hello", response.Body.AsString());
- }
- [Fact]
- public void Should_return_httpstatuscode_value_from_get_route_as_response_with_content_set_as_value()
- {
- // Given
- // When
- var response = this.browser.Get("/httpstatuscode");
- // Then
- Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
- }
- [Fact]
- public void Should_return_action_value_as_response_with_content_set_as_value()
- {
- // Given
- // When
- var response = this.browser.Get("/action");
- // Then
- Assert.Equal("Hiya Nancy!", response.Body.AsString());
- }
- }
Add Comment
Please, Sign In to add comment