コード例 #1
0
        private static ExtensionConfigurationSection GetExtensionConfigurationSection(IHaveConfigurationSectionName sectionNameProvider, ILoadConfigurationSection sectionProvider)
        {
            string sectionName = sectionNameProvider.SectionName;

            return(sectionProvider.GetSection(sectionName) as ExtensionConfigurationSection ??
                   ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string>()));
        }
コード例 #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);
        }
コード例 #3
0
        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");
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #6
0
        public void CreateSection_WithParams_MustBuildUpCorrectConfigurationSection()
        {
            var section = ExtensionConfigurationSectionHelper.CreateSection(new KeyValuePair <string, string>("A", "B"));

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