private static ExtensionConfigurationSection GetExtensionConfigurationSection(IHaveConfigurationSectionName sectionNameProvider, ILoadConfigurationSection sectionProvider)
        {
            string sectionName = sectionNameProvider.SectionName;

            return(sectionProvider.GetSection(sectionName) as ExtensionConfigurationSection ??
                   ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string>()));
        }
Ejemplo n.º 2
0
        private void SetupExtensionConfigurationSectionWithEntries()
        {
            var configurationSection = ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string> {
                { "AnyKey", "AnyValue" }
            });

            this.sectionProvider.Setup(p => p.GetSection(It.IsAny <string>())).Returns(configurationSection);
        }
        public void CreateSection_MustBuildUpCorrectConfigurationSection()
        {
            var section = ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string> {
                { "A", "B" }, { "C", "D" },
            });

            section.Configuration["A"].Value.Should().Be("B");
            section.Configuration["C"].Value.Should().Be("D");
        }
Ejemplo n.º 4
0
        public void Behave_ShouldNotProceedWhenNoConfigurationAvailable()
        {
            var configurationSection = ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string>());

            this.sectionProvider.Setup(p => p.GetSection(It.IsAny <string>())).Returns(configurationSection);

            this.testee.Behave(this.extensions);

            this.consumer.Verify(c => c.Configuration, Times.Never());
            this.assigner.Verify(a => a.Assign(It.IsAny <IReflectExtensionProperties>(), It.IsAny <IExtension>(), It.IsAny <IConsumeConfiguration>(), It.IsAny <IHaveConversionCallbacks>()), Times.Never());
        }
Ejemplo n.º 5
0
        public void Behave_ShouldConsumeSectionFromProvider()
        {
            var expectedConfiguration = new KeyValuePair <string, string>("AnyKey", "AnyValue");
            var configuration         = new Dictionary <string, string>();

            var configurationSection = ExtensionConfigurationSectionHelper.CreateSection(expectedConfiguration);

            this.sectionProvider.Setup(p => p.GetSection(It.IsAny <string>())).Returns(configurationSection);
            this.consumer.Setup(c => c.Configuration).Returns(configuration);

            this.testee.Behave(this.extensions);

            configuration.Should().Contain(expectedConfiguration);
        }
        public void CreateSection_WithParams_MustBuildUpCorrectConfigurationSection()
        {
            var section = ExtensionConfigurationSectionHelper.CreateSection(new KeyValuePair <string, string>("A", "B"));

            section.Configuration["A"].Value.Should().Be("B");
        }