public ConfigurationSectionBehaviorTest() { this.consumer = A.Fake <IConsumeConfigurationSection>(); this.sectionNameProvider = A.Fake <IHaveConfigurationSectionName>(); this.sectionProvider = A.Fake <ILoadConfigurationSection>(); this.factory = A.Fake <IConfigurationSectionBehaviorFactory>(); this.AutoStubFactory(); this.extensions = new List <IExtension> { A.Fake <IExtension>(), A.Fake <IExtension>(), }; this.testee = new ConfigurationSectionBehavior(this.factory); }
/// <inheritdoc /> public void Behave(IEnumerable <IExtension> extensions) { Ensure.ArgumentNotNull(extensions, "extensions"); foreach (IExtension extension in extensions) { IConsumeConfigurationSection consumer = this.factory.CreateConsumeConfigurationSection(extension); IHaveConfigurationSectionName sectionNameProvider = this.factory.CreateHaveConfigurationSectionName(extension); ILoadConfigurationSection sectionProvider = this.factory.CreateLoadConfigurationSection(extension); string sectionName = sectionNameProvider.SectionName; ConfigurationSection section = sectionProvider.GetSection(sectionName); consumer.Apply(section); } }
/// <summary> /// Initializes a new instance of the <see cref="ConsumeConfigurationSection"/> class. /// </summary> /// <param name="extension">The extension.</param> public ConsumeConfigurationSection(IExtension extension) { var consumerCandidate = extension as IConsumeConfigurationSection; this.consumer = consumerCandidate ?? new NullConsumer(); }
/// <summary> /// Initializes a new instance of the <see cref="ConsumeConfigurationSection"/> class. /// </summary> /// <param name="extension">The extension.</param> public ConsumeConfigurationSection(IExtension extension) { var consumerCandidate = extension as IConsumeConfigurationSection; this.consumer = consumerCandidate ?? new DefaultConsumer(); }