Exemplo n.º 1
0
        public void LogOn_Post_ReturnsRedirectOnSuccess_WithLocalReturnUrl()
        {
            var memberService = MockRepository.GenerateStub <IMembershipService>();

            memberService.Stub(x => x.MinPasswordLength).Return(10);
            memberService.Stub(x => x.ValidateUser("someUser", "goodPassword")).Return(true);
            var formService = MockRepository.GenerateMock <IFormsAuthenticationService>();

            formService.Expect(x => x.SignIn("someUser", false));
            // Arrange


            var controller = new StubAccountController {
                FormsService = formService, MembershipService = memberService
            };

            //AccountController controller = GetAccountController();
            LogOnModel model = new LogOnModel()
            {
                UserName   = "******",
                Password   = "******",
                RememberMe = false
            };

            // Act
            ActionResult result = controller.LogOn(model, "/someUrl");

            // Assert
            Assert.IsInstanceOfType(result, typeof(RedirectResult));
            RedirectResult redirectResult = (RedirectResult)result;

            Assert.AreEqual("/someUrl", redirectResult.Url);
            formService.VerifyAllExpectations();
        }
        public void LogOn_Post_ReturnsRedirectOnSuccess_WithLocalReturnUrl()
        {
            var memberService = MockRepository.GenerateStub<IMembershipService>();
            memberService.Stub(x => x.MinPasswordLength).Return(10);
            memberService.Stub(x => x.ValidateUser("someUser", "goodPassword")).Return(true);
            var formService = MockRepository.GenerateMock<IFormsAuthenticationService>();
            formService.Expect(x => x.SignIn("someUser", false));
            // Arrange

            var controller = new StubAccountController {FormsService = formService, MembershipService = memberService};

            //AccountController controller = GetAccountController();
            LogOnModel model = new LogOnModel()
            {
                UserName = "******",
                Password = "******",
                RememberMe = false
            };

            // Act
            ActionResult result = controller.LogOn(model, "/someUrl");

            // Assert
            Assert.IsInstanceOfType(result, typeof(RedirectResult));
            RedirectResult redirectResult = (RedirectResult)result;
            Assert.AreEqual("/someUrl", redirectResult.Url);
            formService.VerifyAllExpectations();
        }