Esempio n. 1
0
        public void CreateOnUserService()
        {
            //arrange
            var mockUserRepository = new Mock<IUserRepository>();
            User userToCreate = new User
                {
                    Id = new Guid("0b21d4b6-eb42-456b-9828-a90cb604bceb"),
                    Password = "******",
                    Username = "******"
                };

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

            UserService userService = new UserService(mockUserRepository.Object);

            //act
            Guid id = userService.Create(userToCreate);

            //assert
            mockUserRepository.Verify(y => y.Create(It.IsAny<User>()));
            Assert.IsNotNull(id);

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

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

            UserService userService = new UserService(mockUserRepository.Object);

            //act
            Guid id = userService.Create(_user);

            //assert - expect exception

            userService.Dispose();
        }