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); }
public async Task SetsStatusCode(JSendResult <IJSendResponse> result) { // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome message.StatusCode.Should().Be(result.StatusCode); }
public async Task SetsContentTypeHeader(JSendResult <IJSendResponse> result) { // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome message.Content.Headers.ContentType.MediaType.Should().Be("application/json"); }
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); }
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); }
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); }
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); }
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."); }
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."); }
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); }
public async Task SerializesResponse(JSendResult <SuccessResponse> result) { // Fixture setup var expectedContent = JsonConvert.SerializeObject(result.Response); // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome var content = await message.Content.ReadAsStringAsync(); content.Should().Be(expectedContent); }
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."); }
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."); }
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); }
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); }
public async Task SerializesResponse(JSendResult<SuccessResponse> result) { // Fixture setup var expectedContent = JsonConvert.SerializeObject(result.Response); // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome var content = await message.Content.ReadAsStringAsync(); content.Should().Be(expectedContent); }
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); }
public async Task SetsStatusCode(JSendResult<IJSendResponse> result) { // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome message.StatusCode.Should().Be(result.StatusCode); }
public async Task SetsContentTypeHeader(JSendResult<IJSendResponse> result) { // Exercise system var message = await result.ExecuteAsync(new CancellationToken()); // Verify outcome message.Content.Headers.ContentType.MediaType.Should().Be("application/json"); }
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); }
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); }
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); }