public void NonDefaults()
    {
        var result = SettingsAttributeReader.ReadFromAttribute(
            new CustomAttributeMock(
                new Dictionary <string, object>
        {
            {
                "ScriptPromotionPath", @"D:\scripts"
            },
            {
                "MsSqlServerScripts", true
            },
            {
                "MySqlScripts", true
            },
            {
                "OracleScripts", true
            },
            {
                "ProduceSagaScripts", false
            },
            {
                "ProduceTimeoutScripts", false
            },
            {
                "ProduceSubscriptionScripts", false
            },
            {
                "ProduceOutboxScripts", false
            }
        }));

        Assert.IsNotNull(result);
        Approver.Verify(result);
    }
    public void Defaults()
    {
        var result = SettingsAttributeReader.ReadFromAttribute(null);

        Assert.IsNotNull(result);
        Approver.Verify(result);
    }
    public void Generate()
    {
        if (clean)
        {
            PurgeDialectDirs(scriptBasePath);
        }

        CreateDirectories();

        Settings settings;

        using (var module = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters(ReadingMode.Deferred)))
        {
            settings = SettingsAttributeReader.Read(module);
            foreach (var dialect in settings.BuildDialects)
            {
                if (!ShouldGenerateDialect(dialect))
                {
                    continue;
                }

                var dialectPath = Path.Combine(scriptBasePath, dialect.ToString());

                CreateDialectDirectory(dialectPath);

                if (settings.ProduceSagaScripts)
                {
                    new SagaWriter(clean, overwrite, dialectPath, module, logError).WriteScripts(dialect);
                }

                if (settings.ProduceTimeoutScripts)
                {
                    new TimeoutWriter(clean, overwrite, dialectPath).WriteScripts(dialect);
                }

                if (settings.ProduceSubscriptionScripts)
                {
                    new SubscriptionWriter(clean, overwrite, dialectPath).WriteScripts(dialect);
                }

                if (settings.ProduceOutboxScripts)
                {
                    new OutboxWriter(clean, overwrite, dialectPath).WriteScripts(dialect);
                }
            }
        }

        var scriptPromotionPath = settings.ScriptPromotionPath;

        if (scriptPromotionPath == null || promotionFinder == null)
        {
            return;
        }
        var replicationPath = promotionFinder(scriptPromotionPath);

        Promote(replicationPath);
    }
    public void Defaults()
    {
        var result = SettingsAttributeReader.ReadFromAttribute(null);

        Assert.IsNotNull(result);
#if NET452
        ObjectApprover.VerifyWithJson(result);
#endif
    }
    public void Minimal()
    {
        var result = SettingsAttributeReader.ReadFromAttribute(
            new CustomAttributeMock(
                new Dictionary <string, object>
        {
            {
                //At least one is required
                "MsSqlServerScripts", true
            }
        }));

        Assert.IsNotNull(result);
        Approver.Verify(result);
    }
        public static void Write(string assemblyPath, string targetDirectory, Action <string, string> logError, Func <string, string> promotionPathFinder)
        {
            var scriptPath = Path.Combine(targetDirectory, "NServiceBus.Persistence.Sql");

            PurgeDialectDirs(scriptPath);
            Directory.CreateDirectory(scriptPath);
            Settings settings;

            using (var module = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters(ReadingMode.Deferred)))
            {
                settings = SettingsAttributeReader.Read(module);
                foreach (var dialect in settings.BuildDialects)
                {
                    var dialectPath = Path.Combine(scriptPath, dialect.ToString());
                    Directory.CreateDirectory(dialectPath);
                    if (settings.ProduceSagaScripts)
                    {
                        SagaWriter.WriteSagaScripts(dialectPath, module, dialect, logError);
                    }
                    if (settings.ProduceTimeoutScripts)
                    {
                        TimeoutWriter.WriteTimeoutScript(dialectPath, dialect);
                    }
                    if (settings.ProduceSubscriptionScripts)
                    {
                        SubscriptionWriter.WriteSubscriptionScript(dialectPath, dialect);
                    }
                    if (settings.ProduceOutboxScripts)
                    {
                        OutboxWriter.WriteOutboxScript(dialectPath, dialect);
                    }
                }
            }

            var scriptPromotionPath = settings.ScriptPromotionPath;

            if (scriptPromotionPath == null)
            {
                return;
            }
            var replicationPath = promotionPathFinder(scriptPromotionPath);

            Promote(replicationPath, scriptPath);
        }