コード例 #1
0
        public void LoggableInitializer_Initialize_InitializationSucceeded_ErrorsShouldBeClear()
        {
            //arrange
            Mock <BasicDatabaseInitializer> mockInitializer = new Mock <BasicDatabaseInitializer>();

            mockInitializer.Setup(x => x.Initialize()).Returns(new ActionResults.InitializationResult(true));
            LoggableDatabaseInitializer testedInstance = new LoggableDatabaseInitializer(mockInitializer.Object);

            //Act
            testedInstance.Initialize();

            //Assert
            Assert.IsFalse(testedInstance.LoggedErrors.Any());
        }
コード例 #2
0
        public void LoggableInitializer_Initialize_InitializationFailed_ShouldLoggedErrors()
        {
            //arrange
            Mock <BasicDatabaseInitializer> mockInitializer = new Mock <BasicDatabaseInitializer>();
            var failErrors = new List <string> {
                "Initialization failed because of reasons"
            };

            mockInitializer.Setup(x => x.Initialize()).Returns(new ActionResults.InitializationResult(false, failErrors));
            LoggableDatabaseInitializer testedInstance = new LoggableDatabaseInitializer(mockInitializer.Object);

            //Act
            testedInstance.Initialize();

            //Assert
            Assert.IsTrue(testedInstance.LoggedErrors.Any());
        }