public void GetItemTest() { var audience = new Audience { Name = "1203" }; _context.Audiences.Add(audience); var repo = new AudLectRepository(_context); var item = new AudLect { Audience = _context.Audiences.FirstOrDefault(x => x.Name == audience.Name), Lection = _context.Lections.FirstOrDefault(s => s.Id == 1), Group = _context.Groups.FirstOrDefault(s => s.Id == 1), TeachSubj = _context.TeachSubjs.FirstOrDefault(t => t.Id == 1) }; repo.AddItem(item); int Id = _context.AudLects.FirstOrDefault(x => x.Audience.Id == item.Audience.Id && x.Lection.Id == item.Lection.Id && x.Group.Id == item.Group.Id && x.TeachSubj.Id == item.TeachSubj.Id).Id; var newitem = repo.GetItem(Id); Assert.AreEqual(item.Audience.Id, newitem.Audience.Id); Assert.AreEqual(item.Lection.Id, newitem.Lection.Id); Assert.AreEqual(item.Group.Id, newitem.Group.Id); Assert.AreEqual(item.TeachSubj.Id, newitem.TeachSubj.Id); _context.AudLects.Remove(item); _context.Audiences.Remove(audience); }
public void AllItemsTest() { var audience = new Audience { Name = "1203" }; _context.Audiences.Add(audience); var repo = new AudLectRepository(_context); Assert.AreEqual(_context.AudLects.Count(), repo.AllItems.Count()); var item1 = new AudLect { Audience = _context.Audiences.FirstOrDefault(x => x.Name == audience.Name), Lection = _context.Lections.FirstOrDefault(s => s.Id == 1), Group = _context.Groups.FirstOrDefault(s => s.Id == 1), TeachSubj = _context.TeachSubjs.FirstOrDefault(t => t.Id == 1) }; repo.AddItem(item1); Assert.AreEqual(_context.AudLects.Count(), repo.AllItems.Count()); _context.AudLects.Remove(item1); _context.Audiences.Remove(audience); }