public void AllItemsTest() { var repo = new StudentsRepository(_context); Assert.AreEqual(_context.Students.Count(), repo.AllItems.Count()); var item1 = new Student { FirstName = "John", MiddleName = "Anthony", LastName = "Cena", Address = "West Newbury", Birthday = new DateTime(1973, 04, 23), Email = "*****@*****.**", LogbookNumber = 4355, Group = _context.Groups.FirstOrDefault() }; var item2 = new Student { FirstName = "Kurt", MiddleName = "Unknown", LastName = "Wallander", Address = "Ystad", Birthday = new DateTime(1961, 05, 23), Email = "*****@*****.**", LogbookNumber = 4366, Group = _context.Groups.FirstOrDefault() }; repo.AddItem(item1); repo.AddItem(item2); Assert.AreEqual(_context.Students.Count(), repo.AllItems.Count()); _context.Students.Remove(item1); _context.Students.Remove(item2); }
public void GetItemTest() { var repo = new StudentsRepository(_context); var item = new Student { FirstName = "John", MiddleName = "Anthony", LastName = "Cena", Address = "West Newbury", Birthday = new DateTime(1973, 04, 23), Email = "*****@*****.**", LogbookNumber = 4355, Group = _context.Groups.FirstOrDefault() }; repo.AddItem(item); int Id = _context.Students.FirstOrDefault(x => x.LogbookNumber == item.LogbookNumber).Id; var newitem = repo.GetItem(Id); Assert.AreEqual(item.FirstName, newitem.FirstName); Assert.AreEqual(item.MiddleName, newitem.MiddleName); Assert.AreEqual(item.LastName, newitem.LastName); Assert.AreEqual(item.Address, newitem.Address); Assert.AreEqual(item.Birthday, newitem.Birthday); Assert.AreEqual(item.Email, newitem.Email); Assert.AreEqual(item.LogbookNumber, newitem.LogbookNumber); _context.Students.Remove(item); }
public void ChangeItemTest() { var repo = new StudentsRepository(_context); var item = new Student { FirstName = "Kurt", MiddleName = "Unknown", LastName = "Wallander", Address = "Ystad", Birthday = new DateTime(1961, 05, 23), Email = "*****@*****.**", LogbookNumber = 4366, Group = _context.Groups.FirstOrDefault() }; repo.AddItem(item); int Id = _context.Students.FirstOrDefault(x => x.LogbookNumber == item.LogbookNumber).Id; var newitem = repo.GetItem(Id); newitem.Email = "*****@*****.**"; repo.ChangeItem(newitem); var gotitem = repo.GetItem(Id); Assert.AreEqual(newitem.FirstName, gotitem.FirstName); Assert.AreEqual(newitem.MiddleName, gotitem.MiddleName); Assert.AreEqual(newitem.LastName, gotitem.LastName); Assert.AreEqual(newitem.Address, gotitem.Address); Assert.AreEqual(newitem.Birthday, gotitem.Birthday); Assert.AreEqual(newitem.Email, gotitem.Email); Assert.AreEqual(newitem.LogbookNumber, gotitem.LogbookNumber); _context.Students.Remove(newitem); }