コード例 #1
0
        public void GivenANormalizerWithDefaultOptionsWhenNormalizedSectionCollectionThenEmptyMustBeRemoved()
        {
            var normalizer = new IniNormalizer();

            var source      = SectionsWithEmptyContent;
            var destination = new List <IniSection>();

            normalizer.NormalizeInto(source, destination);

            Assert.NotEmpty(destination);
            Assert.False(destination.Any(e => e.IsEmpty));
        }
コード例 #2
0
        public void GivenANormalizerMergingSectionsWhenNormalizedSectionCollectionThenDuplicatedWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                MergeOnDuplicatedSections = true
            });

            var source      = SectionsWithDuplicatedCaseInsensitiveNames;
            var destination = new List <IniSection>();

            normalizer.NormalizeInto(source, destination);

            Assert.Equal(1, destination.Count);
        }
コード例 #3
0
        public void GivenANormalizerCaseSensitiveWhenNormalizedSectionCollectionThenCaseSensitiveKeysWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                IsCaseSensitive = true
            });

            var source      = SectionsWithDuplicatedCaseInsensitiveNames;
            var destination = new List <IniSection>();

            normalizer.NormalizeInto(source, destination);

            Assert.Equal(source.Length, destination.Count);
        }
コード例 #4
0
        public void GivenANormalizerWithDefaultOptionsWhenNormalizedSectionCollectionThenDuplicatedMustFaild()
        {
            var normalizer = new IniNormalizer();

            var source      = SectionsWithDuplicatedCaseInsensitiveNames;
            var destination = new List <IniSection>();

            var ex = Assert.Throws <DuplicatedSection>(() =>
            {
                normalizer.NormalizeInto(source, destination);
            });

            Assert.NotNull(ex.SectionName);
        }
コード例 #5
0
        public void GivenANormalizerIgnoringExceptionsWhenNormalizedPropertyCollectionThenDuplicatedWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                ThrowExceptions = false
            });

            var source      = PropertiesWithDuplicatedCaseInsensitiveKeys;
            var destination = new List <IniProperty>();

            normalizer.NormalizeInto(source, destination);

            Assert.Equal(source.Length / 2, destination.Count);
        }
コード例 #6
0
        public void GivenANormalizerIncludingEmptyPropertiesWhenNormalizedSectionCollectionThenEmptyMustBeKept()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                IncludeEmptySections = true
            });

            var source      = SectionsWithEmptyContent;
            var destination = new List <IniSection>();

            normalizer.NormalizeInto(source, destination);

            Assert.Equal(source.Length, destination.Count);
            Assert.True(destination.Any(e => e.IsEmpty));
        }