public void GetAllBugsShouldReturnBugsCollection() { // Arrange -> Prepare the objects var bugs = this.GenerateBugsCollection(); // Act -> Test the objects var bugRepository = new BugRepository(new BugLoggerDbContext()); var bugsInDatabaseCountOld = bugRepository.All().Count(); foreach (var bug in bugs) { bugRepository.Add(bug); } bugRepository.SaveChanges(); // Assert -> Validate the result Assert.AreEqual(bugsInDatabaseCountOld + bugs.Count, bugRepository.All().Count()); CollectionAssert.AreEquivalent(bugs.ToList(), bugRepository.All().OrderBy(b => b.BugId).Skip(bugsInDatabaseCountOld).Take(bugs.Count).ToList()); }
public void GetAllBugsShouldReturnBugsCollection() { // Arrange -> Prepare the objects var bugs = this.GenerateBugsCollection(); // Act -> Test the objects var bugRepository = new BugRepository(new BugLoggerDbContext()); var bugsInDatabaseCountOld = bugRepository.All().Count(); foreach (var bug in bugs) { bugRepository.Add(bug); } bugRepository.SaveChanges(); // Assert -> Validate the result Assert.AreEqual(bugsInDatabaseCountOld + bugs.Count, bugRepository.All().Count()); CollectionAssert.AreEquivalent(bugs.ToList(), bugRepository.All().OrderBy(b => b.BugId).Skip(bugsInDatabaseCountOld).Take(bugs.Count).ToList()); }