Пример #1
0
        public void DeleteItemTest()
        {
            var repo = new MarksRepository(_context);
            var item = new Mark
            {
                Student      = _context.Students.FirstOrDefault(),
                TeachSubj    = _context.TeachSubjs.FirstOrDefault(),
                StudentsMark = 55
            };

            repo.AddItem(item);
            int Id = _context.Marks.FirstOrDefault(x => x.Student.Id == item.Student.Id &&
                                                   x.TeachSubj.Id == item.TeachSubj.Id &&
                                                   x.StudentsMark == item.StudentsMark).Id;
            var newitem = repo.GetItem(Id);

            Assert.AreEqual(item.StudentsMark, newitem.StudentsMark);
            Assert.AreEqual(item.Student.Id, newitem.Student.Id);
            Assert.AreEqual(item.TeachSubj.TeacherId, newitem.TeachSubj.TeacherId);
            Assert.AreEqual(item.TeachSubj.SubjId, newitem.TeachSubj.SubjId);
            repo.DeleteItem(Id);
            Assert.AreEqual(item.StudentsMark, repo.GetItem(Id).StudentsMark);
        }