コード例 #1
0
        public void Write01()
        {
            string content =
                @"# [Category] SQL
# [Description] Database connection string
# [Editor] ConnectionString
c1 <- 'DSN'

x <- 1
";
            IReadOnlyList <IConfigurationSetting> settings;
            var sr = new StreamReader(ToStream(content));

            using (var csr = new ConfigurationSettingsReader(sr)) {
                settings = csr.LoadSettings();
            }

            var stream = new MemoryStream();

            using (var csw = new ConfigurationSettingsWriter(new StreamWriter(stream))) {
                csw.SaveSettings(settings);

                stream.Seek(0, SeekOrigin.Begin);
                using (var r = new StreamReader(stream)) {
                    var s = r.ReadToEnd();
                    s.Should().StartWith(Resources.SettingsFileHeader);
                    s.Should().Contain(content);
                }
            }
        }
コード例 #2
0
        private void LoadAndWrite(string originalContent, string expectedContent)
        {
            IReadOnlyList <IConfigurationSetting> settings;
            var sr = new StreamReader(ToStream(originalContent));

            using (var csr = new ConfigurationSettingsReader(sr)) {
                settings = csr.LoadSettings();
            }

            var stream = new MemoryStream();

            using (var csw = new ConfigurationSettingsWriter(new StreamWriter(stream))) {
                csw.SaveSettings(settings);

                stream.Seek(0, SeekOrigin.Begin);
                using (var r = new StreamReader(stream)) {
                    var s = r.ReadToEnd();
                    s.Should().StartWith(Resources.SettingsFileHeader);
                    s.Should().Contain(expectedContent);
                }
            }
        }