Пример #1
0
        public void AuthenticateUser_DisplaysFlash_When_Login_Failed()
        {
            var service = MockRepository.GenerateStub<ISecurityService>();
            var controller = new ProfileController(service);
            service.Stub(p => p.AuthenticateUser(null, null)).IgnoreArguments().Return(false);
            PrepareController(controller);

            controller.AuthenticateUser("John", "Doe");

            Assert.NotNull(controller.Flash["failure"]);
        }
Пример #2
0
        public void AuthenticateUser_RedirectsToHome_When_Login_Successful()
        {
            var service = MockRepository.GenerateStub<ISecurityService>();
            service.Stub(p => p.AuthenticateUser(null, null)).IgnoreArguments().Return(true);
            service.Stub(p => p.GetAdministrator(null, null)).IgnoreArguments().Return(ObjectMother.GetAdministrator());
            var controller = new ProfileController(service);
            PrepareController(controller);

            controller.AuthenticateUser(null, null); //Doesn't matter. The Stub returns true

            Assert.Equal("/Home/Index.castle", Response.RedirectedTo);
        }