Ejemplo n.º 1
0
        public void AddThreeBugsToRepoAndCheckWhetherAllReturnsTheCorrectBugs()
        {
            //arrange
            var context = new BugLoggerDbContext();
            var repo    = new BugsRepository(context);

            var countInDbBeforeAddingThreeBugs = context.Bugs.Count();

            var bug1 = new Bug
            {
                Content = "test bug 1"
            };

            var bug2 = new Bug
            {
                Content = "test bug 2"
            };

            var bug3 = new Bug
            {
                Content = "test bug 3"
            };

            //act
            context.Bugs.Add(bug1);
            context.Bugs.Add(bug2);
            context.Bugs.Add(bug3);
            context.SaveChanges();

            //assert
            var countInDbAfterAddingThreeBugs = repo.All().ToList().Count;

            Assert.AreEqual(3, countInDbAfterAddingThreeBugs - countInDbBeforeAddingThreeBugs);
        }