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 GetAllBugsShouldReturnBugsCollection() { // Arrange var bugs = this.GenerateBugsCollection(); var bugLoggerFakeData = new BugLoggerFakeUoW(); bugLoggerFakeData.AddBugEntities(bugs); var bugsController = new BugsController(bugLoggerFakeData); // Act var result = bugsController.All(); // Assert Assert.AreEqual(bugs.Count, result.Count()); CollectionAssert.AreEquivalent(bugs.ToList(), result.ToList()); }
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 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); }