Esempio n. 1
0
    public void Init(string workingDirectory)
    {
        var configFilePath       = this.configFileLocator.GetConfigFilePath(workingDirectory);
        var currentConfiguration = this.configFileLocator.ReadConfig(workingDirectory);

        var config = this.configInitWizard.Run(currentConfiguration, workingDirectory);

        if (config == null || configFilePath == null)
        {
            return;
        }

        using var stream = this.fileSystem.OpenWrite(configFilePath);
        using var writer = new StreamWriter(stream);
        this.log.Info("Saving config file");
        ConfigSerializer.Write(config, writer);
        stream.Flush();
    }
        public void Should_Write_Default_Boolean_Values()
        {
            // Given
            var config = new Config();

            config.Create.IncludeFooter = false; // Just to be sure it is a false value

            // When
            var builder = new StringBuilder();

            using (var writer = new StringWriter(builder))
            {
                ConfigSerializer.Write(config, writer);
            }

            // Then
            Assert.That(builder.ToString(), Contains.Substring("include-footer: false"));
        }
        private static string GetOverrideConfigHash(Config overrideConfig)
        {
            if (overrideConfig == null)
            {
                return(string.Empty);
            }

            // Doesn't depend on command line representation and
            // includes possible changes in default values of Config per se.
            var stringBuilder = new StringBuilder();

            using (var stream = new StringWriter(stringBuilder))
            {
                ConfigSerializer.Write(overrideConfig, stream);
                stream.Flush();
            }
            var configContent = stringBuilder.ToString();

            return(GetHash(configContent));
        }