コード例 #1
0
        public void AuthenticateWithInvalidPasswordOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();

            mockUserRepository.Setup(x => x.GetAll()).Returns(_users);

            UserService userService = new UserService(mockUserRepository.Object);

            //act
            User retUser = userService.Authenticate(_user.Username, _user.Password + "WRONG");

            //assert - expect exception

            userService.Dispose();
        }
コード例 #2
0
        public void AuthenticateWithNoExistentUserOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();

            mockUserRepository.Setup(x => x.GetAll()).Returns(_users);

            UserService userService = new UserService(mockUserRepository.Object);

            //act
            User retUser = userService.Authenticate(_user.Username + "DOESNTEXIST", _user.Password);

            //assert - expect exception

            userService.Dispose();
        }
コード例 #3
0
        public void AuthenticateValidPasswordOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();

            mockUserRepository.Setup(x => x.GetAll()).Returns(_users);

            UserService userService = new UserService(mockUserRepository.Object);

            //act
            User retUser = userService.Authenticate(_user.Username, _user.Password);

            //assert
            Assert.AreEqual(_user, retUser);

            userService.Dispose();
        }