public async Task EchoWithAcceptHeaderAsync() { var request = new AutoWebServiceRequest <EchoResponseResponse>(new Uri(m_uriPrefix + "echo")) .WithAccept("text/plain"); var response = await request.GetResponseAsync(); Assert.IsNotNull(response.OK); Assert.AreEqual("text/plain", response.OK !.RequestHeaders !.GetValueOrDefault("Accept")); }
public async Task EchoNoContentAsync() { var request = new AutoWebServiceRequest <EchoResponseResponse>(new Uri(m_uriPrefix + "echo")) .WithJsonContent(new EchoRequestDto { StatusCode = 204, SendContent = false }); var response = await request.GetResponseAsync(); Assert.IsTrue(response.NoContent); }
public async Task EchoGenericStatusCodeAsIntResponse(HttpStatusCode statusCode) { var request = new AutoWebServiceRequest <EchoResponseGenericStatusCodeAsIntResponse>(new Uri(m_uriPrefix + "echo")) .WithJsonContent(new EchoRequestDto { StatusCode = (int)statusCode }); var response = await request.GetResponseAsync(); Assert.AreEqual((int)statusCode, response.StatusCode); }
public async Task EchoGenericStatusCodeResponse(HttpStatusCode statusCode) { var request = new AutoWebServiceRequest <GenericStatusCodeResponse>(new Uri(m_uriPrefix + "echo")) .WithJsonContent(new EchoRequestDto { StatusCode = (int)statusCode }); var response = await request.GetResponseAsync(); Assert.AreEqual(statusCode, response.StatusCode); CollectionAssert.IsNotEmpty(response.Headers); }
public async Task EchoWithMessageAsync() { var request = new AutoWebServiceRequest <EchoResponseResponse>(new Uri(m_uriPrefix + "echo")) .WithPostMethod() .WithJsonContent(new EchoRequestDto { Message = "hello" }); var response = await request.GetResponseAsync(); Assert.IsNotNull(response.OK); Assert.AreEqual("POST", response.OK !.Method); Assert.AreEqual("hello", response.OK.Message); }
public void EchoInternalError() { var request = new AutoWebServiceRequest <EchoResponseResponse>(new Uri(m_uriPrefix + "echo")) .WithJsonContent(new EchoRequestDto { StatusCode = 500 }); var exception = Assert.ThrowsAsync <WebServiceException>(async() => await request.GetResponseAsync()); Assert.AreEqual(HttpStatusCode.InternalServerError, exception.ResponseStatusCode); }