Ejemplo n.º 1
0
        public void DeleteItemTest()
        {
            var repo = new TeachersRepository(_context);
            var item = new Teacher
            {
                FirstName  = "Kate",
                MiddleName = "Mary",
                LastName   = "March",
                Department = _context.Departments.FirstOrDefault()
            };

            repo.AddItem(item);
            int Id = _context.Teachers.FirstOrDefault(x => x.FirstName == item.FirstName &&
                                                      x.MiddleName == item.MiddleName &&
                                                      x.LastName == item.LastName).Id;

            Assert.AreEqual(item.FirstName, repo.GetItem(Id).FirstName);
            Assert.AreEqual(item.MiddleName, repo.GetItem(Id).MiddleName);
            Assert.AreEqual(item.LastName, repo.GetItem(Id).LastName);
            repo.DeleteItem(Id);
            Assert.AreEqual(item.LastName, repo.GetItem(Id).LastName);
        }