private void MethodNotAllowedServiceTest(bool asynchronousSendEnabled, bool streamed) { using (var host = TestServiceHost.CreateWebHost <TestService>(asynchronousSendEnabled, false, streamed, new HttpMessageHandlerFactory(typeof(TestHandler)))) { using (var client = TestServiceClient.CreateClient(false, TestServiceCommon.ServiceAddress)) { var result = TestServiceClient.RunClient(client, TestHeaderOptions.InsertRequest | TestHeaderOptions.ValidateResponse, HttpMethod.Options); foreach (var httpResponse in result) { TestServiceCommon.ValidateMethodNotAllowedResponse(httpResponse); } } } }
private void MissingPropertyServiceTest(bool asynchronousSendEnabled, bool faultDetail, bool streamed) { using (var host = TestServiceHost.CreateWebHost <TestService>(asynchronousSendEnabled, faultDetail, streamed, new HttpMessageHandlerFactory(typeof(TestHandler)))) { using (var client = TestServiceClient.CreateClient(false, TestServiceCommon.ServiceAddress)) { var result = TestServiceClient.RunClient(client, TestHeaderOptions.InsertRequest | TestHeaderOptions.ValidateResponse); foreach (var httpResponse in result) { TestServiceCommon.ValidateInternalServerErrorResponse(httpResponse, faultDetail); } } } }
private void NoDataServiceTest(bool asynchronousSendEnabled, bool streamed, bool copyHeaderInHandler) { NoDataServiceTests.CopyHeaderInHandler = copyHeaderInHandler; using (var host = TestServiceHost.CreateWebHost <TestService>(asynchronousSendEnabled, false, streamed, new HttpMessageHandlerFactory(typeof(TestHandler)))) { using (var client = TestServiceClient.CreateClient()) { var result = TestServiceClient.RunClient(client, TestHeaderOptions.InsertRequest | TestHeaderOptions.ValidateResponse); foreach (var httpResponse in result) { Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode); Assert.AreEqual(TestWebServiceBase.HttpReasonPhrase, httpResponse.ReasonPhrase); Assert.AreEqual(0, httpResponse.Content.Headers.ContentLength); Assert.IsNull(httpResponse.Content.Headers.ContentType); } } } }
private void PersistenceTest(bool asynchronousSendEnabled, bool streamed) { using (var host = TestServiceHost.CreateWebHost <TestService>(asynchronousSendEnabled, false, streamed, new HttpMessageHandlerFactory(typeof(TestHandler)))) { using (var client = TestServiceClient.CreateClient()) { var result = TestServiceClient.RunClient(client, TestHeaderOptions.ValidateResponse); foreach (var httpResponse in result) { Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode); Assert.AreEqual(TestWebServiceBase.HttpReasonPhrase, httpResponse.ReasonPhrase); Assert.AreEqual("text/plain", httpResponse.Content.Headers.ContentType.MediaType); Assert.AreEqual("utf-8", httpResponse.Content.Headers.ContentType.CharSet); var body = httpResponse.Content.ReadAsString(); Assert.AreEqual(body, TestWebServiceBase.HttpResponseContent); } } } }
private void DisposeHandlerTest(bool asynchronousSendEnabled, bool streamed) { DisposeHandlerTests.handlerList = new List <TestHandler>(); using (var host = TestServiceHost.CreateWebHost <TestService>(asynchronousSendEnabled, false, streamed, new HttpMessageHandlerFactory(typeof(TestHandler)))) { using (var client = TestServiceClient.CreateClient()) { var result = TestServiceClient.RunClient(client, TestHeaderOptions.InsertRequest | TestHeaderOptions.ValidateResponse); foreach (var httpResponse in result) { Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode); Assert.AreEqual(TestWebServiceBase.HttpReasonPhrase, httpResponse.ReasonPhrase); } Assert.AreEqual(1, DisposeHandlerTests.handlerList.Count); Assert.IsFalse(DisposeHandlerTests.handlerList[0].IsDisposed); } } Assert.AreEqual(1, DisposeHandlerTests.handlerList.Count); Assert.IsTrue(DisposeHandlerTests.handlerList[0].IsDisposed); }