Beispiel #1
0
        public void Test_FromObject_Build_ReturnsConfigurationProvider()
        {
            // Arrange
            var source = new Box <string>("VALUE");

            // Act
            var result = ObjectConfigurationSource
                         .FromObject(source)
                         .Build(builderMock);

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the properties of the specified <paramref name="source"/>
        /// as configuration entries to the <see cref="IConfigurationBuilder"/>,
        /// mapping property-names to keys and property-values to values,
        /// including nested objects.
        /// </summary>
        /// <param name="builder">The builder to which to add the configuration entries.</param>
        /// <param name="source">The object from which the properties are obtained.</param>
        /// <typeparam name="T">The type of the specified <paramref name="source"/></typeparam>
        /// <returns>The specified <see cref="IConfigurationBuilder"/> for chaining.</returns>
        /// <Example>
        /// builder.AddObject( ("value1", "value2") );
        /// </Example>
        public static IConfigurationBuilder AddObject <T>(this IConfigurationBuilder builder, T source)
        {
            if (builder == null)
            {
                throw new System.ArgumentNullException(nameof(builder));
            }

            if (source == null)
            {
                throw new System.ArgumentNullException(nameof(source));
            }

            return(builder.Add(ObjectConfigurationSource.FromObject(source)));
        }
        public void Build_creates_a_provider(ObjectConfigurationSource sut, IConfigurationBuilder configurationBuilder)
        {
            var provider = sut.Build(configurationBuilder);

            Assert.That(provider, Is.InstanceOf <ObjectConfigurationProvider>());
        }