public void ConfigureDesignTimeServices_is_noop_when_not_found()
        {
            var startup = new StartupInvoker(
                typeof(StartupInvokerTest).GetTypeInfo().Assembly,
                environment: "Unknown");

            startup.ConfigureDesignTimeServices(new ServiceCollection());
        }
        public void ConfigureDesignTimeServices_uses_Development_environment_when_unspecified()
        {
            var services = new ServiceCollection();
            var startup  = new StartupInvoker(
                typeof(StartupInvokerTest).GetTypeInfo().Assembly,
                environment: null);

            startup.ConfigureDesignTimeServices(services);

            var service = services.BuildServiceProvider().GetRequiredService <TestService>();

            Assert.Equal("Development", service.Value);
        }
        public void ConfigureDesignTimeServices_invokes_static_methods()
        {
            var services = new ServiceCollection();
            var startup  = new StartupInvoker(
                typeof(StartupInvokerTest).GetTypeInfo().Assembly,
                "Static");

            startup.ConfigureDesignTimeServices(services);

            var service = services.BuildServiceProvider().GetRequiredService <TestService>();

            Assert.Equal("Static", service.Value);
        }
        public void ConfigureDesignTimeServices_works_on_other_types()
        {
            var services = new ServiceCollection();
            var startup  = new StartupInvoker(
                typeof(StartupInvokerTest).GetTypeInfo().Assembly,
                environment: null);

            startup.ConfigureDesignTimeServices(typeof(NotStartup), services);

            var service = services.BuildServiceProvider().GetRequiredService <TestService>();

            Assert.Equal("NotStartup", service.Value);
        }
示例#5
0
 private void ConfigureProviderServices(string provider, IServiceCollection services, bool throwOnError = false)
 => _startup.ConfigureDesignTimeServices(GetProviderDesignTimeServices(provider, throwOnError), services);