Example #1
0
        public void TestAddUserShouldNotAddExistingUserToTheList()
        {
            User newUser = new User
            {
                Email         = "*****@*****.**",
                Name          = "El SeƱor",
                LastName      = "De Los Completos",
                UserName      = "******",
                Password      = "******",
                Administrator = false
            };
            IEnumerable <User>     fakeUsers          = GetFakeUsers();
            Mock <IUserRepository> mockUserRepository = new Mock <IUserRepository>();
            IUserManagementService userLogic          = new UserManagementService()
            {
                UserRepository = mockUserRepository.Object
            };

            mockUserRepository
            .Setup(wl => wl.Exists(newUser.Email))
            .Returns(true);

            User result = userLogic.Add(newUser);

            mockUserRepository.VerifyAll();
        }