public void AllItemsTest() { //_context.Subjects.RemoveRange(_context.Subjects); var repo = new SubjectsRepository(_context); Assert.AreEqual(_context.Subjects.Count(), repo.AllItems.Count()); var item1 = new Subject { Name = "Data Engineering" }; var item2 = new Subject { Name = "Automation Theory" }; repo.AddItem(item1); repo.AddItem(item2); Assert.AreEqual(_context.Subjects.Count(), repo.AllItems.Count()); _context.Subjects.Remove(item1); _context.Subjects.Remove(item2); }
public void GetItemTest() { //_context.Subjects.RemoveRange(_context.Subjects); var repo = new SubjectsRepository(_context); var item = new Subject { Name = "Automation Theory" }; repo.AddItem(item); int Id = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Id; Assert.AreEqual(item.Name, repo.GetItem(Id).Name); _context.Subjects.Remove(item); }
public void AddItemTest() { //_context.Subjects.RemoveRange(_context.Subjects); var repo = new SubjectsRepository(_context); var item = new Subject { Name = "Data Engineering" }; repo.AddItem(item); string name = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Name; Assert.AreEqual(item.Name, name); _context.Subjects.Remove(item); }
public void ChangeItemTest() { //_context.Subjects.RemoveRange(_context.Subjects); var repo = new SubjectsRepository(_context); var item = new Subject { Name = "Biology" }; repo.AddItem(item); int Id = _context.Subjects.FirstOrDefault(x => x.Name == item.Name).Id; var newitem = repo.GetItem(Id); newitem.Name = "Chemistry"; repo.ChangeItem(newitem); Assert.AreEqual(newitem.Name, _context.Subjects.FirstOrDefault(x => x.Name == newitem.Name).Name); _context.Subjects.Remove(newitem); }