private static ExtensionConfigurationSection GetExtensionConfigurationSection(IHaveConfigurationSectionName sectionNameProvider, ILoadConfigurationSection sectionProvider) { string sectionName = sectionNameProvider.SectionName; return(sectionProvider.GetSection(sectionName) as ExtensionConfigurationSection ?? ExtensionConfigurationSectionHelper.CreateSection(new Dictionary <string, string>())); }
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"); }
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()); }
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"); }