public void AddBug_WhenBugIsNotValid_ShouldThrowException() { var bug = GetInvalidTestBug(); var dbContext = new BugLoggerDbContext(); var repo = new DbBugsRepository(dbContext); repo.Add(bug); repo.Save(); }
public void DeleteBug_WhenNotInDb_ShouldThrowExcetion() { var bug = GetValidTestBug(); var dbContext = new BugLoggerDbContext(); var repo = new DbBugsRepository(dbContext); repo.Delete(bug); repo.Save(); }
public void DeleteBug_WhenInDb_ShouldRemoveBug() { var bug = GetValidTestBug(); var dbContext = new BugLoggerDbContext(); var repo = new DbBugsRepository(dbContext); repo.Add(bug); repo.Save(); var bugInDb = dbContext.Bugs.Find(bug.Id); Assert.IsNotNull(bugInDb); Assert.AreEqual(bug.Text, bugInDb.Text); repo.Delete(bug); repo.Save(); bugInDb = dbContext.Bugs.Find(bug.Id); Assert.IsNull(bugInDb); }
public void AddBug_WhenBugIsValid_ShouldAddToDb() { var bug = GetValidTestBug(); var dbContext = new BugLoggerDbContext(); var repo = new DbBugsRepository(dbContext); repo.Add(bug); repo.Save(); var bugInDb = dbContext.Bugs.Find(bug.Id); Assert.IsNotNull(bugInDb); Assert.AreEqual(bug.Text, bugInDb.Text); }
public void AddBug_WhenBugIsValid_ShouldAddToDb() { //// arrange -> prapare the objects var bug = this.GetValidTestBug(); var dbContext = new BugLoggerDbContext(); var repo = new DbBugsRepository(dbContext); //// act -> test the objects repo.Add(bug); repo.Save(); //// assert -> validate the result var bugInDb = dbContext.Bugs.Find(bug.Id); Assert.IsNotNull(bugInDb); Assert.AreEqual(bug.Text, bugInDb.Text); }