Exemplo n.º 1
0
        public void BuildResponseOkTest()
        {
            var request = new HttpRequestMessage();

            request.SetConfiguration(new HttpConfiguration());

            var serviceResponse = new FakeServiceResponse {
                Result = true
            };

            var builder = new HttpResponseBuilder();

            var response = builder.BuildResponse(request, serviceResponse);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("true", response.Content.ReadAsStringAsync().Result);
        }
Exemplo n.º 2
0
        public void BuildResponseEntityInvalidTest()
        {
            var request = new HttpRequestMessage();

            request.SetConfiguration(new HttpConfiguration());

            var serviceResponse = new FakeServiceResponse
            {
                Result    = false,
                Exception = new ValidationException("test")
            };

            var builder = new HttpResponseBuilder();

            var response = builder.BuildResponse(request, serviceResponse);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.AreEqual("test", response.Content.ReadAsStringAsync().Result);
        }