Ejemplo n.º 1
0
        public void DeleteUser_ExistingUser_UserIsNotPresentInTheDB()
        {
            Guid userId;
            var  user = new User
            {
                AccessType = AccountAccessType.Full,
                Email      = "*****@*****.**",
                Name       = "SomeUser"
            };
            var userModel = _mapper.Map <User, UserModel>(user);

            using (var dbContext = new ExpenseDbContext(Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                dbContext.Users.Add(userModel);
                dbContext.SaveChanges();
                userId = userModel.Id;
            }
            user.Id = userId;

            // Act
            _accountFacade.DeleteUser(user.Id);

            // Assert
            bool userExistsInDb;

            using (var dbContext = new ExpenseDbContext(Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                userExistsInDb = dbContext.Users.Find(user.Id) != null;
            }

            Assert.AreEqual(userExistsInDb, false, "DeleteUser failed - users still exists in the db.");
        }