public async Task endpoint_invocation___returns_true_for_null_controller_method() { var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { } }, Routing = new ApiRoutingInfo { Route = new ApiRoutingItem { Location = new ApiEndpointLocation( controller: null, methodInfo: null, httpMethod: null) } } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }
public async Task endpoint_invocation___returns_true_for_api_response_and_empty_parameter_endpoint() { var controller = new StandardController(); var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { ControllerInstance = controller, } }, Routing = new ApiRoutingInfo { Route = new ApiRoutingItem { Location = new ApiEndpointLocation( controller: controller.GetType(), methodInfo: controller.GetType().GetMethod(nameof(controller.DefaultFullApiResponseEndpoint)), httpMethod: null) } } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().NotBeNull(); context.Response.ResponseObject.Should().BeOfType <int>(); context.Response.ResponseObject.Should().Be(200); }
public async Task endpoint_invocation___returns_false_for_cancelled_request() { var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(true) }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeFalse(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }
public async Task endpoint_invocation___returns_true_for_api_response_and_uri_and_body_parameter_and_extra_parameters_endpoint() { var controller = new StandardController(); var uriModel = new StandardModel { IntProp = 204 }; var bodyModel = new StandardNullableModel { IntProp = 301 }; var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { ControllerInstance = controller, UriModel = uriModel, BodyModel = bodyModel } }, Routing = new ApiRoutingInfo { Route = new ApiRoutingItem { Location = new ApiEndpointLocation( controller: controller.GetType(), methodInfo: controller.GetType().GetMethod(nameof(controller.DefaultFullApiResponseEndpointWithUriParameterAndBodyParameterAndExtraParameters)), httpMethod: null) } } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.StatusCode.Should().Be(200); context.Response.ResponseObject.Should().BeOfType <int>(); context.Response.ResponseObject.Should().Be(301); }
public async Task endpoint_invocation___returns_true_for_null_invocation_context() { var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = null } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }
public async Task endpoint_invocation___returns_true_for_void_and_empty_parameter_endpoint() { var controller = new StandardController(); var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { ControllerInstance = controller, //ControllerMethod = controller.GetType().GetMethod(nameof(controller.DefaultEndpoint)) } } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }