public async Task HandleRequest_PerCallControllerWithArgs_MatchConstructor() { int age = 15; var m = new RestWebServer(); m.RegisterController <HappyPathTestPerCallControllerWithArgs>(() => new object[] { "Johathan", age++ }); var response = await m.HandleRequest(_basicControllerWithArgs); StringAssert.Contains(response.Response, "\"Name\":\"Johathan\""); StringAssert.Contains(response.Response, "\"Age\":15"); response = await m.HandleRequest(_basicControllerWithArgs); StringAssert.Contains(response.Response, "\"Name\":\"Johathan\""); StringAssert.Contains(response.Response, "\"Age\":16"); }
public async Task HandleRequest_BasicGETAbsoluteUri_Status200() { var m = new RestWebServer(); m.RegisterController<HappyPathTestController>(); var response = await m.HandleRequest(_basicGETAbsoluteUri); StringAssert.Contains(response.ToString(), "200 OK"); }
public async Task HandleRequest_BasicGETUriPrefix_Status200() { var m = new RestWebServer(8800, "api"); m.RegisterController<HappyPathTestController>(); var response = await m.HandleRequest(_basicGETUriPrefix); StringAssert.Contains(response.Response, "200 OK"); }
public async Task HandleRequest_WrongParameterTypePUT_BadRequest() { var m = new RestWebServer(); m.RegisterController<RaiyDayTestController>(); var response = await m.HandleRequest(_parameterParseExceptionPUT); StringAssert.Contains(response.Response, "400 Bad Request"); }
public async Task HandleRequest_BasicPUT_MethodNotAllowed() { var m = new RestWebServer(); m.RegisterController<RaiyDayTestController>(); var response = await m.HandleRequest(_methodNotAllowedPUT); StringAssert.Contains(response.Response, "405 Method Not Allowed"); StringAssert.Contains(response.Response, "Allow: POST"); }
public async Task HandleRequest_CreateWithExistingId_Conflicted() { var m = new RestWebServer(); m.RegisterController<RaiyDayTestController>(); var response = await m.HandleRequest(_conflictingPOST); StringAssert.Contains(response.Response, "409 Conflict"); StringAssert.DoesNotMatch(response.Response, new Regex("Location:")); }
public async Task HandleRequest_BasicGETUriPrefix_Status200() { var m = new RestWebServer(8800, "api"); m.RegisterController <HappyPathTestController>(); var response = await m.HandleRequest(_basicGETUriPrefix); StringAssert.Contains(response.Response, "200 OK"); }
public async Task HandleRequest_WrongParameterTypePUT_BadRequest() { var m = new RestWebServer(); m.RegisterController <RaiyDayTestController>(); var response = await m.HandleRequest(_parameterParseExceptionPUT); StringAssert.Contains(response.Response, "400 Bad Request"); }
public async Task HandleRequest_InvalidJsonBodyParameter_BadRequest() { var m = new RestWebServer(); m.RegisterController <RaiyDayTestController>(); var response = await m.HandleRequest(_invalidXmlFormatExPOST); StringAssert.Contains(response.Response, "400 Bad Request"); }
public async Task HandleRequest_CreateWithExistingId_Conflicted() { var m = new RestWebServer(); m.RegisterController <RaiyDayTestController>(); var response = await m.HandleRequest(_conflictingPOST); StringAssert.Contains(response.Response, "409 Conflict"); StringAssert.DoesNotMatch(response.Response, new Regex("Location:")); }
public async Task HandleRequest_ControllerWithArgs_MatchConstructor() { var m = new RestWebServer(); m.RegisterController <HappyPathTestSingletonControllerWithArgs>("Johathan", 15); var response = await m.HandleRequest(_basicControllerWithArgs); StringAssert.Contains(response.Response, "\"Name\":\"Johathan\""); StringAssert.Contains(response.Response, "\"Age\":15"); }
public async Task HandleRequest_BasicPOST_LocationHeaderStatus201() { var m = new RestWebServer(); m.RegisterController <HappyPathTestController>(); var response = await m.HandleRequest(_basicPOST); StringAssert.Contains(response.Response, "201 Created"); StringAssert.Contains(response.Response, "Location: /users/2"); }
public async Task HandleRequest_BasicPUT_MethodNotAllowed() { var m = new RestWebServer(); m.RegisterController <RaiyDayTestController>(); var response = await m.HandleRequest(_methodNotAllowedPUT); StringAssert.Contains(response.Response, "405 Method Not Allowed"); StringAssert.Contains(response.Response, "Allow: POST"); }
public async Task HandleRequest_BasicGETAcceptXML_Status200WithXml() { var m = new RestWebServer(); m.RegisterController<HappyPathTestController>(); var response = await m.HandleRequest(_basicGETAcceptXML); StringAssert.Contains(response.Response, "200 OK"); StringAssert.Contains(response.Response, "Content-Type: application/xml"); StringAssert.Contains(response.Response, "<Name>Tom</Name>"); StringAssert.Contains(response.Response, "<Age>30</Age>"); }
public async Task HandleRequest_BasicGETAcceptXML_Status200WithXml() { var m = new RestWebServer(); m.RegisterController <HappyPathTestController>(); var response = await m.HandleRequest(_basicGETAcceptXML); StringAssert.Contains(response.Response, "200 OK"); StringAssert.Contains(response.Response, "Content-Type: application/xml"); StringAssert.Contains(response.Response, "<Name>Tom</Name>"); StringAssert.Contains(response.Response, "<Age>30</Age>"); }
public async Task HandleRequest_BasicGETAcceptJSON_Status200WithJSON() { var m = new RestWebServer(); m.RegisterController <HappyPathTestController>(); var response = await m.HandleRequest(_basicGETAcceptJSON); StringAssert.Contains(response.Response, "200 OK"); StringAssert.Contains(response.Response, "Content-Type: application/json"); StringAssert.Contains(response.Response, "\"Name\":\"Tom\""); StringAssert.Contains(response.Response, "\"Age\":30"); }
public async Task HandleRequest_PerCallControllerWithArgs_MatchConstructor() { int age = 15; var m = new RestWebServer(); m.RegisterController<HappyPathTestPerCallControllerWithArgs>(() => new object[] { "Johathan", age++ }); var response = await m.HandleRequest(_basicControllerWithArgs); string content = response.ToString(); StringAssert.Contains(content, "\"Name\":\"Johathan\""); StringAssert.Contains(content, "\"Age\":15"); response = await m.HandleRequest(_basicControllerWithArgs); content = response.ToString(); StringAssert.Contains(content, "\"Name\":\"Johathan\""); StringAssert.Contains(content, "\"Age\":16"); }
public async Task HandleRequest_ControllerWithArgs_MatchConstructor() { var m = new RestWebServer(); m.RegisterController<HappyPathTestSingletonControllerWithArgs>("Johathan", 15); var response = await m.HandleRequest(_basicControllerWithArgs); string content = response.ToString(); StringAssert.Contains(content, "\"Name\":\"Johathan\""); StringAssert.Contains(content, "\"Age\":15"); }
public async Task HandleRequest_BasicPOST_LocationHeaderStatus201() { var m = new RestWebServer(); m.RegisterController<HappyPathTestController>(); var response = await m.HandleRequest(_basicPOST); string content = response.ToString(); StringAssert.Contains(content, "201 Created"); StringAssert.Contains(content, "Location: /users/2"); }
public async Task HandleRequest_BasicGETAcceptJSON_Status200WithJSON() { var m = new RestWebServer(); m.RegisterController<HappyPathTestController>(); var response = await m.HandleRequest(_basicGETAcceptJSON); string content = response.ToString(); StringAssert.Contains(content, "200 OK"); StringAssert.Contains(content, "Content-Type: application/json"); StringAssert.Contains(content, "\"Name\":\"Tom\""); StringAssert.Contains(content, "\"Age\":30"); }
public async Task HandleRequest_InvalidXMLContentParameter_BadRequest() { var m = new RestWebServer(); m.RegisterController<RaiyDayTestController>(); var response = await m.HandleRequest(_xmlContentParameterParseExPOST); StringAssert.Contains(response.ToString(), "400 Bad Request"); }
public async Task HandleRequest_InvalidJsonBodyParameter_BadRequest() { var m = new RestWebServer(); m.RegisterController<RaiyDayTestController>(); var response = await m.HandleRequest(_invalidXmlFormatExPOST); StringAssert.Contains(response.Response, "400 Bad Request"); }