Example #1
0
        public void AddBugToRepoAndTestWhetherFindReturnsTheCorrectBug()
        {
            //arrange
            var context = new BugLoggerDbContext();
            var repo    = new BugsRepository(context);

            var bug = new Bug
            {
                Content = "Please fix my blog"
            };

            //act
            context.Bugs.Add(bug);
            context.SaveChanges();

            //assert
            var bugFromDb = repo.Find(bug.BugId);

            Assert.AreEqual(bug.Content, bugFromDb.Content);
        }
Example #2
0
        public void AddBugAndUpdateItThenCheckWhetherTheUpdatesAreReflected()
        {
            //arrange
            var context = new BugLoggerDbContext();
            var repo    = new BugsRepository(context);

            var bug = new Bug
            {
                Content = "New bug"
            };

            //act
            repo.Add(bug);
            repo.SaveChanges();

            bug.Status = BugStatus.Assigned;
            repo.SaveChanges();

            //assert
            var bugFromDb = repo.Find(bug.BugId);

            Assert.AreEqual(BugStatus.Assigned, bugFromDb.Status);
        }
        public void AddBug_WhenBugIsAddedToDb_ShouldReturnBug()
        {
            // Arrange -> prapare the objects
            var repo = new BugsRepository(new BugTrackerDbContext());
            var bug  = new Bug()
            {
                Text        = "Sample New Bug",
                DateCreated = DateTime.Now,
                Status      = BugStatus.New
            };

            // Act -> perform some logic
            repo.Add(bug);
            repo.SaveChanges();

            // Assert -> validate the results
            var bugFromDb = repo.Find(bug.Id);

            Assert.IsNotNull(bugFromDb);
            Assert.AreEqual(bug.Text, bugFromDb.Text);
            Assert.AreEqual(bug.Status, bugFromDb.Status);
            Assert.AreEqual(bug.DateCreated, bugFromDb.DateCreated);
            Assert.IsTrue(bugFromDb.Id != 0);
        }
        public void AddBug_WhenBugIsAddedToDb_ShouldReturnBug()
        {
            // Arrange -> prapare the objects
            var repo = new BugsRepository(new BugTrackerDbContext());
            var bug = new Bug()
            {
                Text = "Sample New Bug",
                DateCreated = DateTime.Now,
                Status = BugStatus.New
            };

            // Act -> perform some logic
            repo.Add(bug);
            repo.SaveChanges();

            // Assert -> validate the results
            var bugFromDb = repo.Find(bug.Id);

            Assert.IsNotNull(bugFromDb);
            Assert.AreEqual(bug.Text, bugFromDb.Text);
            Assert.AreEqual(bug.Status, bugFromDb.Status);
            Assert.AreEqual(bug.DateCreated, bugFromDb.DateCreated);
            Assert.IsTrue(bugFromDb.Id != 0);
        }