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);
        }
Example #2
0
        public void GetAllBugsShouldReturnBugsCollection_Mocking()
        {
            // Arrange
            var bugs = this.GenerateBugsCollection();
            var bugLoggerFakeData = this.MockUnitOfWorkForActionAll(bugs);
            var bugsController = new BugsController(bugLoggerFakeData);
            
            // Act
            var result = bugsController.All();

            // Assert
            CollectionAssert.AreEquivalent(bugs.ToList(), result.ToList());
        }
Example #3
0
        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 TestInit()
 {
     this.controller = new BugsController(this.repository);
 }
Example #6
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);
        }