Exemplo n.º 1
0
        public void UpdateToExistingUsernameOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();

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

            UserService userService = new UserService(mockUserRepository.Object);

            //set username to that of another user
            _user.Username = _users[0].Username;

            //act
            userService.Update(_user);

            //assert - expected exception

            userService.Dispose();
        }
Exemplo n.º 2
0
        public void UpdateOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();

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

            UserService userService = new UserService(mockUserRepository.Object);

            //set username to that of another user
            _user.Username = _user.Username + "WITHUPDATE";

            //act
            userService.Update(_user);

            //assert - expected exception
            mockUserRepository.Verify(y => y.Update(It.IsAny<User>()));

            userService.Dispose();
        }