Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public void GetItemExceptionTest()
 {
     var repo  = new MarksRepository(_context);
     var item1 = repo.GetItem(-1).StudentsMark;
 }