public void WithPermanent_GivenExpected_ShouldPass()
		{
            ActionResult result = new RedirectToRouteResult("", null, true);
            result.Should()
                    .BeRedirectToRouteResult()
                    .WithPermanent(true);
		}
 public void WithRouteName_GivenExpected_ShouldPass()
 {
     ActionResult result = new RedirectToRouteResult("default", null);
     result.Should()
             .BeRedirectToRouteResult()
             .WithRouteName("default");
 }
        public void TestRedirectToRouteResult_should_work_as_expected_with_method_without_arguments()
        {
            ApiControllerHttpActionResultActionTester actionTester = _controllerTester.Action(x => x.HttpActionResultActionWithoutArguments);

            _controller.HttpActionResult = new RedirectToRouteResult("test", new Dictionary <string, object>(), _controller);

            RedirectToRouteResult result          = null;
            RedirectToRouteResult validatedResult = null;
            bool validateWasCalled = false;

            Action action = () =>
            {
                result = actionTester.TestRedirectToRouteResult(r =>
                {
                    validatedResult   = r;
                    validateWasCalled = true;
                });
            };

            action.Should().NotThrow();
            result.Should().Be(_controller.HttpActionResult);
            validateWasCalled.Should().BeTrue();
            validatedResult.Should().Be(_controller.HttpActionResult);

            _controller.HttpActionResult = _okResult;
            action.Should().Throw <ControllerTestException>().WithMessage(
                "Expected IHttpActionResult type System.Web.Http.Results.RedirectToRouteResult. Actual: System.Web.Http.Results.OkResult.");
        }
        public void ProductVariantController_DeletePOST_ShouldReturnARedirectToRouteResult()
        {
            ProductVariant productVariant = GetNewProductVariant();

            RedirectToRouteResult delete = _productVariantController.Delete_POST(productVariant);

            delete.Should().BeOfType <RedirectToRouteResult>();
        }
示例#5
0
        public void WithPermanent_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", null, true);

            result.Should()
            .BeRedirectToRouteResult()
            .WithPermanent(true);
        }
示例#6
0
        public void WithRouteName_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("default", null);

            result.Should()
            .BeRedirectToRouteResult()
            .WithRouteName("default");
        }
 public void WithPermanent_GivenUnExpected_ShouldFail()
 {
     ActionResult result = new RedirectToRouteResult("", null, true);
     Action a = () => result.Should()
             .BeRedirectToRouteResult()
             .WithPermanent(false);
     a.ShouldThrow<Exception>()
             .WithMessage("Expected RedirectToRoute.Permanent to be False, but found True");
 }
 public void WithRouteName_GivenUnExpected_ShouldFail()
 {
     ActionResult result = new RedirectToRouteResult("default", null);
     Action a = () => result.Should()
             .BeRedirectToRouteResult()
             .WithRouteName("xyz");
     a.ShouldThrow<Exception>()
         .WithMessage("Expected RedirectToRoute.RouteName to be \"xyz\", but found \"default\"");
 }
示例#9
0
        public void WithRouteName_GivenUnExpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("default", null);
            Action       a      = () => result.Should()
                                  .BeRedirectToRouteResult()
                                  .WithRouteName("xyz");

            a.ShouldThrow <Exception>()
            .WithMessage("Expected RedirectToRoute.RouteName to be \"xyz\", but found \"default\"");
        }
示例#10
0
        public void WithPermanent_GivenUnExpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", null, true);
            Action       a      = () => result.Should()
                                  .BeRedirectToRouteResult()
                                  .WithPermanent(false);

            a.ShouldThrow <Exception>()
            .WithMessage("Expected RedirectToRoute.Permanent to be False, but found True");
        }
        public void WithPermanent_GivenUnExpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", null, true);
            Action       a      = () => result.Should()
                                  .BeRedirectToRouteResult()
                                  .WithPermanent(false, Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(FailureMessageHelper.ExpectedContextToBeXButY("RedirectToRoute.Permanent", false, true));
        }
        public void WithRouteName_GivenUnExpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("default", null);
            Action       a      = () => result.Should()
                                  .BeRedirectToRouteResult()
                                  .WithRouteName("xyz", Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(FailureMessageHelper.ExpectedContextToBeXButY("RedirectToRoute.RouteName", "xyz", "default"));
        }
        public void WithArea_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Area = "accounts"
            }));

            result.Should()
            .BeRedirectToRouteResult()
            .WithArea("accounts");
        }
        public void WithController_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Controller = "home"
            }));

            result.Should()
            .BeRedirectToRouteResult()
            .WithController("home");
        }
        public void WithRouteValue_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Id = "22"
            }));

            result.Should()
            .BeRedirectToRouteResult()
            .WithRouteValue("Id", "22");
        }
        public void WithAction_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Action = "index"
            }));

            result.Should()
            .BeRedirectToRouteResult()
            .WithAction("index");
        }
        public void WithRouteValue_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Id = "22"
                }));

            result.Should()
                    .BeRedirectToRouteResult()
                    .WithRouteValue("Id", "22");
        }
        public void WithArea_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Area = "accounts"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithArea("xyz", Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(FailureMessageHelper.ExpectedAtKeyValueXButFoundY("RedirectToRouteResult.RouteValues", "Area", "xyz", "accounts"));
        }
        public void WithController_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Controller = "home"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithController("xyz", Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(FailureMessageHelper.ExpectedAtKeyValueXButFoundY("RedirectToRouteResult.RouteValues", "Controller", "xyz", "home"));
        }
        public void WithRouteValue_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Id = "22"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithRouteValue("Id", "11", Reason, ReasonArgs);

            a.Should().Throw <Exception>()
            .WithMessage(FailureMessageHelper.ExpectedAtKeyValueXButFoundY("RedirectToRouteResult.RouteValues", "Id", "11", "22"));
        }
示例#21
0
        public void WithController_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Controller = "home"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithController("xyz");

            a.Should().Throw <Exception>()
            .WithMessage("Expected dictionary to contain value \"xyz\" at key \"Controller\", but found \"home\".");
        }
示例#22
0
        public void WithRouteValue_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Id = "22"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithRouteValue("Id", "11");

            a.Should().Throw <Exception>()
            .WithMessage("Expected result to contain value \"11\" at key \"Id\", but found \"22\".");
        }
示例#23
0
        public void WithArea_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new {
                Area = "accounts"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithArea("xyz");

            a.Should().Throw <Exception>()
            .WithMessage("Expected dictionary to contain value \"xyz\" at key \"Area\", but found \"accounts\".");
        }
        public void WithRouteValue_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Id = "22"
                }));

            Action a = () => result.Should()
                    .BeRedirectToRouteResult()
                    .WithRouteValue("Id", "11");
            a.ShouldThrow<Exception>()
                    .WithMessage("Expected dictionary to contain value \"11\" at key \"Id\", but found \"22\".");            
        }
示例#25
0
        public void WithAction_GivenUnexpected_ShouldFail()
        {
            var subjectIdentifier = GetSubjectIdentifier();

            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                                                                new
            {
                Action = "index"
            }));

            Action a = () => result.Should()
                       .BeRedirectToRouteResult()
                       .WithAction("xyz");

            a.Should().Throw <Exception>()
            .WithMessage($"Expected {subjectIdentifier} to contain value \"xyz\" at key \"Action\", but found \"index\".");
        }
        public void WithController_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Controller = "home"
                }));

            Action a = () => result.Should()
                    .BeRedirectToRouteResult()
                    .WithController("xyz");
            a.ShouldThrow<Exception>()
                    .WithMessage("Expected dictionary to contain value \"xyz\" at key \"Controller\", but found \"home\".");
        }
        public void WithArea_GivenUnexpected_ShouldFail()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Area = "accounts"
                }));

            Action a = () => result.Should()
                    .BeRedirectToRouteResult()
                    .WithArea("xyz");
            a.ShouldThrow<Exception>()
                    .WithMessage("Expected dictionary to contain value \"xyz\" at key \"Area\", but found \"accounts\".");
        }
        public void WithController_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Controller = "home"
                }));

            result.Should()
                    .BeRedirectToRouteResult()
                    .WithController("home");
        }
        public void WithAction_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Action = "index"
                }));

            result.Should()
                    .BeRedirectToRouteResult()
                    .WithAction("index");
        }
        public void WithArea_GivenExpected_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult("", new RouteValueDictionary(
                new
                {
                    Area = "accounts"
                }));

            result.Should()
                    .BeRedirectToRouteResult()
                    .WithArea("accounts");
        }
 public void BeRedirectToRoute_GivenRedirectToRoute_ShouldPass()
 {
     ActionResult result = new RedirectToRouteResult(new RouteValueDictionary());
     result.Should().BeRedirectToRouteResult();
 }
示例#32
0
        public void BeRedirectToRoute_GivenRedirectToRoute_ShouldPass()
        {
            ActionResult result = new RedirectToRouteResult(new RouteValueDictionary());

            result.Should().BeRedirectToRouteResult();
        }