Ejemplo n.º 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"));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }