コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
 /// <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();
 }