예제 #1
0
 public void CanBeCreatedWithControllerWithoutProperties(HttpStatusCode status, IJSendResponse response,
     [NoAutoProperties] TestableJSendApiController controller)
 {
     // Exercise system and verify outcome
     Action ctor = () => new JSendResult<IJSendResponse>(status, response, controller);
     ctor.ShouldNotThrow();
 }
예제 #2
0
        public void RequestIsCorrectlyInitialized(HttpStatusCode status, IJSendResponse response, HttpRequestMessage request)
        {
            // Exercise system
            var result = new JSendResult <IJSendResponse>(status, response, request);

            // Verify outcome
            result.Request.Should().Be(request);
        }
예제 #3
0
        public void ResponseIsCorrectlyInitialized(HttpStatusCode code, IJSendResponse response,
                                                   ApiController controller)
        {
            // Exercise system
            var result = new JSendResult <IJSendResponse>(code, response, controller);

            // Verify outcome
            result.Response.Should().BeSameAs(response);
        }
예제 #4
0
 public void ExecuteThrowsWhenRequestHasNoContext(HttpStatusCode status, IJSendResponse response)
 {
     // Fixture setup
     var request = new HttpRequestMessage();
     var result = new JSendResult<IJSendResponse>(status, response, request);
     // Exercise system and verify outcome
     result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
         .ShouldThrow<InvalidOperationException>()
         .WithMessage(StringResources.Request_RequestContextMustNotBeNull);
 }
예제 #5
0
 public void ExecuteThrowsWhenControllerHasNoRequest(HttpStatusCode status, IJSendResponse response,
     [NoAutoProperties] TestableJSendApiController controller)
 {
     // Fixture setup
     var result = new JSendResult<IJSendResponse>(status, response, controller);
     // Exercise system and verify outcome
     result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
         .ShouldThrow<InvalidOperationException>()
         .WithMessage("ApiController.Request must not be null.");
 }
예제 #6
0
        public void ExecuteThrowsWhenRequestHasNoContext(HttpStatusCode status, IJSendResponse response)
        {
            // Fixture setup
            var request = new HttpRequestMessage();
            var result  = new JSendResult <IJSendResponse>(status, response, request);

            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
            .ShouldThrow <InvalidOperationException>()
            .WithMessage(StringResources.Request_RequestContextMustNotBeNull);
        }
예제 #7
0
        public void ExecuteThrowsWhenControllerHasNoRequest(HttpStatusCode status, IJSendResponse response,
                                                            [NoAutoProperties] TestableJSendApiController controller)
        {
            // Fixture setup
            var result = new JSendResult <IJSendResponse>(status, response, controller);

            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
            .ShouldThrow <InvalidOperationException>()
            .WithMessage("ApiController.Request must not be null.");
        }
예제 #8
0
        public void ExecuteThrowsWhenRequestContextHasNoConfiguration(HttpRequestMessage request, HttpStatusCode status,
            IJSendResponse response)
        {
            // Fixture setup
            var requestContext = new HttpRequestContext();
            request.SetRequestContext(requestContext);

            var result = new JSendResult<IJSendResponse>(status, response, request);
            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
                .ShouldThrow<InvalidOperationException>()
                .WithMessage("HttpRequestContext.Configuration must not be null.");
        }
예제 #9
0
        public void ExecuteThrowsWhenControllerHasNoJsonFormatter(HttpStatusCode status, IJSendResponse response,
            ApiController controller)
        {
            // Fixture setup
            var formatters = controller.Configuration.Formatters;
            formatters.OfType<JsonMediaTypeFormatter>().ToList()
                .ForEach(f => formatters.Remove(f));

            var result = new JSendResult<IJSendResponse>(status, response, controller);
            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
                .ShouldThrow<InvalidOperationException>()
                .WithMessage(StringResources.ConfigurationMustContainFormatter);
        }
예제 #10
0
        public void ExecuteThrowsWhenRequestContextHasNoConfiguration(HttpRequestMessage request, HttpStatusCode status,
                                                                      IJSendResponse response)
        {
            // Fixture setup
            var requestContext = new HttpRequestContext();

            request.SetRequestContext(requestContext);

            var result = new JSendResult <IJSendResponse>(status, response, request);

            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
            .ShouldThrow <InvalidOperationException>()
            .WithMessage("HttpRequestContext.Configuration must not be null.");
        }
예제 #11
0
        public void CanBeCreatedWithControllerWithoutProperties(HttpStatusCode status, IJSendResponse response,
                                                                [NoAutoProperties] TestableJSendApiController controller)
        {
            // Exercise system and verify outcome
            Action ctor = () => new JSendResult <IJSendResponse>(status, response, controller);

            ctor.ShouldNotThrow();
        }
예제 #12
0
        public void RequestIsCorrectlyInitializedUsingController(HttpStatusCode status, IJSendResponse response, ApiController controller)
        {
            // Exercise system
            var result = new JSendResult <IJSendResponse>(status, response, controller);

            // Verify outcome
            result.Request.Should().Be(controller.Request);
        }
예제 #13
0
        public void StatusCodeIsCorrectlyInitialized(HttpStatusCode expectedStatusCode, IJSendResponse response,
                                                     ApiController controller)
        {
            // Exercise system
            var result = new JSendResult <IJSendResponse>(expectedStatusCode, response, controller);

            // Verify outcome
            result.StatusCode.Should().Be(expectedStatusCode);
        }
예제 #14
0
 public void RequestIsCorrectlyInitialized(HttpStatusCode status, IJSendResponse response, HttpRequestMessage request)
 {
     // Exercise system
     var result = new JSendResult<IJSendResponse>(status, response, request);
     // Verify outcome
     result.Request.Should().Be(request);
 }
예제 #15
0
 public void ResponseIsCorrectlyInitialized(HttpStatusCode code, IJSendResponse response,
     ApiController controller)
 {
     // Exercise system
     var result = new JSendResult<IJSendResponse>(code, response, controller);
     // Verify outcome
     result.Response.Should().BeSameAs(response);
 }
예제 #16
0
 public void RequestIsCorrectlyInitializedUsingController(HttpStatusCode status, IJSendResponse response, ApiController controller)
 {
     // Exercise system
     var result = new JSendResult<IJSendResponse>(status, response, controller);
     // Verify outcome
     result.Request.Should().Be(controller.Request);
 }
예제 #17
0
        public void ExecuteThrowsWhenControllerHasNoJsonFormatter(HttpStatusCode status, IJSendResponse response,
                                                                  ApiController controller)
        {
            // Fixture setup
            var formatters = controller.Configuration.Formatters;

            formatters.OfType <JsonMediaTypeFormatter>().ToList()
            .ForEach(f => formatters.Remove(f));

            var result = new JSendResult <IJSendResponse>(status, response, controller);

            // Exercise system and verify outcome
            result.Awaiting(r => r.ExecuteAsync(CancellationToken.None))
            .ShouldThrow <InvalidOperationException>()
            .WithMessage(StringResources.ConfigurationMustContainFormatter);
        }
예제 #18
0
 public void StatusCodeIsCorrectlyInitialized(HttpStatusCode expectedStatusCode, IJSendResponse response,
     ApiController controller)
 {
     // Exercise system
     var result = new JSendResult<IJSendResponse>(expectedStatusCode, response, controller);
     // Verify outcome
     result.StatusCode.Should().Be(expectedStatusCode);
 }