Exemplo n.º 1
0
        public void Test_Add_user()
        {
            DbContext   dbContext  = new DbContextMock("TestAddUser");
            Users       user       = User();
            IUnitOfWork unitOfWork = new UnitOfWork(dbContext  as INutritionalCalculatorContext);
            var         response   = unitOfWork.Users.Add(user);

            dbContext.SaveChanges();
            var response2 = dbContext.Find <Users>(response.UserName);

            Assert.AreEqual(response, dbContext.Find <Users>(response.Id));
        }
Exemplo n.º 2
0
        public void Test_Delete_Users()
        {
            DbContext dbContext = new DbContextMock("TestDelete");
            Users     user      = User();

            AddUser(user, dbContext);
            IUnitOfWork unitOfWork = new UnitOfWork(dbContext as INutritionalCalculatorContext);

            unitOfWork.Users.Delete(user);
            dbContext.SaveChanges();
            Assert.AreEqual(null, dbContext.Find <Users>(user.Id));
        }
Exemplo n.º 3
0
        public void Test_Update()
        {
            DbContext dbContext = new DbContextMock("TestUpdate");
            Users     user      = User();

            dbContext.Add(user);
            dbContext.SaveChanges();
            IUnitOfWork unitOfWork = new UnitOfWork(dbContext as INutritionalCalculatorContext);

            user.FirstName = "First name test edited";
            unitOfWork.Users.update(user);
            dbContext.SaveChanges();
            Assert.AreEqual(dbContext.Find <Users>(user.Id).FirstName, user.FirstName);
        }