public void Configure_WithNullForBuilder_ThrowsException() { var sut = new SimpleInjectorStartup <StartupStub, ConfigurationStub>(); var exception = Assert.Throws <ArgumentNullException>(() => sut.Configure(null)); Assert.That(exception.ParamName, Is.EqualTo("builder")); }
public void GenericsOverload_WithDefaultConfiguration_GetsTheRightConfig() { var sut = new SimpleInjectorStartup <StartupStub>(); sut.Configure(_builder); var provider = _builder.Services.BuildServiceProvider(); var startup = provider.GetService <IStartup>(); Assert.That(startup, Is.TypeOf <StartupStub>()); var serviceProviderHolder = provider.GetService <IServiceProviderHolder>(); var logger = serviceProviderHolder.GetRequiredService(typeof(ILogger)); Assert.That(logger, Is.SameAs(_internalLogger)); var loggerOfT = serviceProviderHolder.GetRequiredService(typeof(ILogger <SimpleInjectorStartupTest>)); Assert.That(loggerOfT, Is.Null); }
public void GenericsOverload_WithNoLoggersConfigured_GetsTheRightConfig() { ConfigurationStub.AddILoggerOfTGlobal = false; ConfigurationStub.AddILoggerGlobal = false; var sut = new SimpleInjectorStartup <StartupStub, ConfigurationStub>(); sut.Configure(_builder); var provider = _builder.Services.BuildServiceProvider(); var startup = provider.GetService <IStartup>(); Assert.That(startup, Is.TypeOf <StartupStub>()); var serviceProviderHolder = provider.GetService <IServiceProviderHolder>(); var logger = serviceProviderHolder.GetRequiredService(typeof(ILogger)); Assert.That(logger, Is.Null); var loggerOfT = serviceProviderHolder.GetRequiredService(typeof(ILogger <SimpleInjectorStartupTest>)); Assert.That(loggerOfT, Is.Null); }