コード例 #1
0
        public void LoggedInUserNoSponsorship()
        {
            var userRepository = MockRepository.GenerateMock<IUserRepository>();
            userRepository.Expect(u => u.IsCurrentSponsor(Arg<string>.Is.Anything)).Return(false);
            var controller = new SponsorController { UserRepository = userRepository };
            var result = controller.Index() as ViewResult;
            Assert.That(result.ViewName, Is.EqualTo("NoSponsorshipOverview"));

            userRepository.VerifyAllExpectations();
        }
コード例 #2
0
        public void NotLoggedIn()
        {
            var userRepository = MockRepository.GenerateMock<IUserRepository>();
            var userNotFoundException = new Exception("User not found");
            userRepository.Expect(u => u.IsCurrentSponsor(Arg<string>.Is.Anything)).Throw(userNotFoundException);
            var controller = new SponsorController { UserRepository = userRepository };
            var result = controller.Index() as ViewResult;
            Assert.That(result.ViewName, Is.EqualTo("Login"));

            userRepository.VerifyAllExpectations();
        }