Example #1
0
        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"));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }