public void ExecutesTheCallbackAsExpected() { var called = false; var services = new Mock <IServiceCollection>(); ConfigurationBuilderRegistration.OnConfigureServicesCallback(services.Object, builder => { called = true; }); Assert.True(called); }
/// <summary> /// Configures the application configuration. /// </summary> /// <param name="builder">The builder instance.</param> /// <param name="callback">The callback which will configure the application configuration.</param> /// <returns>The builder instance.</returns> public static IRuntimeHostBuilder ConfigureAppConfiguration(this IRuntimeHostBuilder builder, Action <IConfigurationBuilder> callback) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } else if (callback == null) { throw new ArgumentNullException(nameof(callback)); } builder.ConfigureServices(services => ConfigurationBuilderRegistration.OnConfigureServicesCallback(services, callback)); return(builder); }
public void ThrowsExceptionWhenCallbackIsNull() { Assert.Throws <ArgumentNullException>(() => ConfigurationBuilderRegistration.OnConfigureServicesCallback(new Mock <IServiceCollection>().Object, null)); }
public void ThrowsExceptionWhenServicesIsNull() { Assert.Throws <ArgumentNullException>(() => ConfigurationBuilderRegistration.OnConfigureServicesCallback(null, builder => { })); }