Ejemplo n.º 1
0
        public void OnFormatting_NullContext_ThrowsArgumentNullException()
        {
            // Act
            var result = new AcceptedAtActionResult("actionName", "controllerName", "routeValues", "value");

            // Assert
            Assert.Throws <ArgumentNullException>("context", () => result.OnFormatting(null));
        }
Ejemplo n.º 2
0
        public void OnFormatting_NullUrlHelperContextNoRequestServices_ThrowsArgumentNullExeption()
        {
            // Arrange
            var context = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());

            // Act
            var result = new AcceptedAtActionResult(actionName: null, controllerName: null, routeValues: null, value: null);

            // Assert
            Assert.Throws <ArgumentNullException>("provider", () => result.OnFormatting(context));
        }
Ejemplo n.º 3
0
        public void OnFormatting_NullUrlHelperContextHasRequestServices_ReturnsRequestServicesAction()
        {
            // Arrange
            var context = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());

            context.HttpContext.RequestServices = new ForwardingServiceProvider();

            // Act
            var result = new AcceptedAtActionResult(actionName: null, controllerName: null, routeValues: null, value: null);

            result.OnFormatting(context);

            // Assert
            var header = context.HttpContext.Response.Headers.Last();

            Assert.Equal("Location", header.Key);
            Assert.Equal("abc", header.Value);
        }