public void AddValidBugShouldBeAddedToRepository() { // Arrange var bugLoggerFakeData = new BugLoggerFakeUoW(); var bug = new CreateBugModel() { Description = "bug-1", LogDate = DateTime.Now }; var bugsController = new BugsController(bugLoggerFakeData); this.SetupController(bugsController); // Act bugsController.Create(bug); // Assert Assert.AreEqual(bugLoggerFakeData.Bugs.All().Count(), 1); var bugInDatabase = bugLoggerFakeData.Bugs.All().First(); Assert.AreEqual(bug.Description, bugInDatabase.Description); Assert.AreEqual(BugStatus.Pending, bugInDatabase.Status); Assert.IsNotNull(bugInDatabase.LogDate); Assert.IsTrue(bugLoggerFakeData.IsSaveChangedCalled); }
public void AddBugWithEmptyDescriptionShouldNotBeAddedToRepository() { // Arrange var bugLoggerFakeData = new BugLoggerFakeUoW(); var bug = new CreateBugModel() { Description = string.Empty, LogDate = DateTime.Now }; var bugsController = new BugsController(bugLoggerFakeData); this.SetupController(bugsController); // Act bugsController.Create(bug); // Assert Assert.AreEqual(bugLoggerFakeData.Bugs.All().Count(), 0); }
public void AddValidBugShouldBeAddedToRepository_Mocking() { // Arrange var bug = new CreateBugModel() { Description = "bug-1" }; var bugs = new List<Bug>(); var bugLoggerFakeData = this.MockUnitOfWorkForActionAll(bugs); var bugsController = new BugsController(bugLoggerFakeData); this.SetupController(bugsController); // Act bugsController.Create(bug); // Assert Assert.AreEqual(bugLoggerFakeData.Bugs.All().Count(), 1); var bugInDatabase = bugLoggerFakeData.Bugs.All().First(); Assert.AreEqual(bug.Description, bugInDatabase.Description); Assert.AreEqual(BugStatus.Pending, bugInDatabase.Status); Assert.IsNotNull(bugInDatabase.LogDate); }
public void AddBugWithoutBothDescriptionAndLogDateShouldNotBeAddedToRepository() { // Arrange var bugLoggerFakeData = new BugLoggerFakeUoW(); var bug = new CreateBugModel(); var bugsController = new BugsController(bugLoggerFakeData); this.SetupController(bugsController); // Act bugsController.Create(bug); // Assert Assert.AreEqual(bugLoggerFakeData.Bugs.All().Count(), 0); }