IScriptModifier IScriptModifierFactory.CreateScriptModifier(ScriptModifier scriptModifier)
        {
            switch (scriptModifier)
            {
            case ScriptModifier.AddCustomHeader:
                return(_dependencyResolver.Get <AddCustomHeaderModifier>());

            case ScriptModifier.AddCustomFooter:
                return(_dependencyResolver.Get <AddCustomFooterModifier>());

            case ScriptModifier.TrackDacpacVersion:
                return(_dependencyResolver.Get <TrackDacpacVersionModifier>());

            case ScriptModifier.CommentOutUnnamedDefaultConstraintDrops:
                return(_dependencyResolver.Get <CommentOutUnnamedDefaultConstraintDropsModifier>());

            case ScriptModifier.ReplaceUnnamedDefaultConstraintDrops:
                return(_dependencyResolver.Get <ReplaceUnnamedDefaultConstraintDropsModifier>());

            case ScriptModifier.RemoveSqlCmdStatements:
                return(_dependencyResolver.Get <RemoveSqlCmdStatementsModifier>());

            default:
                throw new ArgumentOutOfRangeException(nameof(scriptModifier), scriptModifier, null);
            }
        }
        public void CreateScriptModifier_ArgumentOutOfRangeException(ScriptModifier scriptModifier)
        {
            // Arrange
            var drMock = Mock.Of <IDependencyResolver>();
            IScriptModifierFactory f = new ScriptModifierFactory(drMock);

            // Act & Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => f.CreateScriptModifier(scriptModifier));
        }
        public void CreateScriptModifier_CorrectCreation(ScriptModifier scriptModifier,
                                                         Type implementingType)
        {
            // Arrange
            var daMock     = Mock.Of <IDacAccess>();
            var loggerMock = Mock.Of <ILogger>();
            var drMock     = new Mock <IDependencyResolver>();

            drMock.Setup(m => m.Get <AddCustomHeaderModifier>()).Returns(new AddCustomHeaderModifier());
            drMock.Setup(m => m.Get <AddCustomFooterModifier>()).Returns(new AddCustomFooterModifier());
            drMock.Setup(m => m.Get <TrackDacpacVersionModifier>()).Returns(new TrackDacpacVersionModifier());
            drMock.Setup(m => m.Get <CommentOutUnnamedDefaultConstraintDropsModifier>()).Returns(new CommentOutUnnamedDefaultConstraintDropsModifier());
            drMock.Setup(m => m.Get <ReplaceUnnamedDefaultConstraintDropsModifier>()).Returns(new ReplaceUnnamedDefaultConstraintDropsModifier(daMock, loggerMock));
            drMock.Setup(m => m.Get <RemoveSqlCmdStatementsModifier>()).Returns(new RemoveSqlCmdStatementsModifier());
            IScriptModifierFactory f = new ScriptModifierFactory(drMock.Object);

            // Act
            var modifier = f.CreateScriptModifier(scriptModifier);

            // Assert
            Assert.IsNotNull(modifier);
            Assert.IsInstanceOf(implementingType, modifier);
        }