public void ChangeItemTest() { var repo = new MarksRepository(_context); var item = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 77 }; 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); newitem.StudentsMark = 83; repo.ChangeItem(newitem); var gotitem = repo.GetItem(Id); Assert.AreEqual(newitem.Student.Id, gotitem.Student.Id); Assert.AreEqual(newitem.StudentsMark, gotitem.StudentsMark); Assert.AreEqual(newitem.TeachSubj.TeacherId, gotitem.TeachSubj.TeacherId); Assert.AreEqual(newitem.TeachSubj.SubjId, gotitem.TeachSubj.SubjId); _context.Marks.Remove(newitem); }
public void AllItemsTest() { var repo = new MarksRepository(_context); Assert.AreEqual(_context.Marks.Count(), repo.AllItems.Count()); var item1 = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 55 }; repo.AddItem(item1); Assert.AreEqual(_context.Marks.Count(), repo.AllItems.Count()); _context.Marks.Remove(item1); }
public void AddItemTest() { var repo = new MarksRepository(_context); var item = new Mark { Student = _context.Students.FirstOrDefault(), TeachSubj = _context.TeachSubjs.FirstOrDefault(), StudentsMark = 55 }; repo.AddItem(item); var newitem = _context.Marks.FirstOrDefault(x => x.Student.Id == item.Student.Id && x.TeachSubj.Id == item.TeachSubj.Id && x.StudentsMark == item.StudentsMark); Assert.AreEqual(item.Student.Id, newitem.Student.Id); Assert.AreEqual(item.StudentsMark, newitem.StudentsMark); Assert.AreEqual(item.TeachSubj.TeacherId, newitem.TeachSubj.TeacherId); Assert.AreEqual(item.TeachSubj.SubjId, newitem.TeachSubj.SubjId); _context.Marks.Remove(item); }