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"));
        }
Exemplo n.º 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            SimpleInjectorStartup.RegisterDependencies(GlobalConfiguration.Configuration);

            ClassMapper.MapDomainModels();
        }
        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);
        }