示例#1
0
        public void GivenANormalizerWithDefaultOptionsWhenTryedToNormalizeSectionCollectionThenDuplicatedMustFaild()
        {
            var normalizer = new IniNormalizer();

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

            Assert.False(normalizer.TryNormalizeInto(source, destination));

            Assert.Equal(0, destination.Count);
        }
示例#2
0
        public void GivenANormalizerWithDefaultOptionsWhenTryedToNormalizeSectionCollectionThenEmptyMustBeRemoved()
        {
            var normalizer = new IniNormalizer();

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

            Assert.True(normalizer.TryNormalizeInto(source, destination));

            Assert.NotEmpty(destination);
            Assert.False(destination.Any(e => e.IsEmpty));
        }
示例#3
0
        public void GivenANormalizerMergingSectionsWhenTryedToNormalizeSectionCollectionThenDuplicatedWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                MergeOnDuplicatedSections = true
            });

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

            Assert.True(normalizer.TryNormalizeInto(source, destination));

            Assert.Equal(1, destination.Count);
        }
示例#4
0
        public void GivenANormalizerIgnoringExceptionsWhenTryedToNormalizeSectionCollectionThenDuplicatedWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                ThrowExceptions = false
            });

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

            Assert.False(normalizer.TryNormalizeInto(source, destination));

            Assert.Equal(0, destination.Count);
        }
示例#5
0
        public void GivenANormalizerCaseSensitiveWhenTryedToNormalizeSectionCollectionThenCaseSensitiveKeysWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                IsCaseSensitive = true
            });

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

            Assert.True(normalizer.TryNormalizeInto(source, destination));

            Assert.Equal(source.Length, destination.Count);
        }
示例#6
0
        public void GivenANormalizerIgnoringExceptionsWhenTryedToNormalizePropertyCollectionThenDuplicatedWillPass()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                ThrowExceptions = false
            });

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

            Assert.True(normalizer.TryNormalizeInto(source, destination));

            Assert.Equal(source.Length / 2, destination.Count);
        }
示例#7
0
        public void GivenANormalizerIncludingEmptyPropertiesWhenTryedToNormalizeSectionCollectionThenEmptyMustBeKept()
        {
            var normalizer = new IniNormalizer(new IniNormalizationOptions
            {
                IncludeEmptySections = true
            });

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

            Assert.True(normalizer.TryNormalizeInto(source, destination));

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