예제 #1
0
    public void StartupWithPrivateConfiguresThrows()
    {
        var serviceCollection = new ServiceCollection();

        serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
        serviceCollection.AddSingleton <IFakeStartupCallback>(new FakeStartupCallback());
        var services = serviceCollection.BuildServiceProvider();

        var diagnosticMessages = new List <string>();
        var type = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "PrivateConfigure");

        var ex = Assert.Throws <InvalidOperationException>(() => StartupLoader.LoadMethods(services, type, "PrivateConfigure"));

        Assert.Equal("A public method named 'ConfigurePrivateConfigure' or 'Configure' could not be found in the 'Microsoft.AspNetCore.Hosting.Fakes.StartupPrivateConfigure' type.", ex.Message);
    }
예제 #2
0
    public void StartupLoaderCanLoadByTypeWithEnvironment()
    {
        var serviceCollection = new ServiceCollection();

        serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
        var services = serviceCollection.BuildServiceProvider();

        var startup = StartupLoader.LoadMethods(services, typeof(TestStartup), "No");

        var app = new ApplicationBuilder(services);

        app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

        Assert.Throws <InvalidOperationException>(() => startup.ConfigureDelegate(app));
    }
예제 #3
0
        public void ConfigureThrowingDoesNotThrowTargetInvocationException()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
            var services = serviceCollection.BuildServiceProvider();

            var startup = StartupLoader.LoadMethods(services, typeof(StartupConfigureThrows), environmentName: null);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

            Assert.Throws <Exception>(() => startup.ConfigureDelegate(app));
        }
예제 #4
0
        public void BadServiceProviderFactoryFailsThatReturnsNullServiceProviderOverriddenByDefault()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <MyContainer>, MyBadContainerFactory>();
            var services = serviceCollection.BuildServiceProvider();

            var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartup), Environments.Development);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

            Assert.NotNull(app.ApplicationServices);
            Assert.IsNotType <MyContainer>(app.ApplicationServices);
        }
예제 #5
0
 public DelegatedStatelessWebServiceStartup(
     IServiceProvider provider,
     IHostingEnvironment env,
     Action <IServiceCollection> configureServices)
 {
     _configureServices = configureServices;
     if (typeof(TStartup).IsAssignableTo <IStartup>())
     {
         _startupImplementation = (IStartup)ActivatorUtilities.CreateInstance <TStartup>(provider);
     }
     else
     {
         StartupMethods methods = StartupLoader.LoadMethods(provider, typeof(TStartup), env.EnvironmentName);
         _startupImplementation = new ConventionBasedStartup(methods);
     }
 }
예제 #6
0
        public void CustomServiceProviderFactoryStartupBaseClassCallsConfigureContainer()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <MyContainer>, MyContainerFactory>();
            var services = serviceCollection.BuildServiceProvider();

            var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

            Assert.IsType <MyContainer>(app.ApplicationServices);
            Assert.True(((MyContainer)app.ApplicationServices).FancyMethodCalled);
        }
예제 #7
0
        public void CustomServiceProviderFactoryEnvironmentBasedConfigureContainer()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <MyContainer>, MyContainerFactory>();
            var services = serviceCollection.BuildServiceProvider();

            var startup = StartupLoader.LoadMethods(services, typeof(MyContainerStartupEnvironmentBased), Environments.Production);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

            Assert.IsType <MyContainer>(app.ApplicationServices);
            Assert.Equal(((MyContainer)app.ApplicationServices).Environment, Environments.Production);
        }
예제 #8
0
        public void StartupClassMayHaveHostingServicesInjected()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IFakeStartupCallback>(this);
            var services = serviceCollection.BuildServiceProvider();

            var type    = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "WithServices");
            var startup = StartupLoader.LoadMethods(services, type, "WithServices");

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            startup.ConfigureDelegate(app);

            Assert.Equal(2, _configurationMethodCalledList.Count);
        }
예제 #9
0
        public void StartupLoaderCanLoadByType()
        {
            var serviceCollection = new ServiceCollection();
            var services          = serviceCollection.BuildServiceProvider();

            var hostingEnv = new HostingEnvironment();
            var startup    = StartupLoader.LoadMethods(services, typeof(TestStartup), hostingEnv.EnvironmentName);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            startup.ConfigureDelegate(app);

            var foo = app.ApplicationServices.GetRequiredService <SimpleService>();

            Assert.Equal("Configure", foo.Message);
        }
예제 #10
0
        public void StartupClassWithConfigureServicesShouldMakeServiceAvailableInConfigure()
        {
            var serviceCollection = new ServiceCollection();
            var services          = serviceCollection.BuildServiceProvider();

            var type    = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "WithConfigureServices");
            var startup = StartupLoader.LoadMethods(services, type, "WithConfigureServices");

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            startup.ConfigureDelegate(app);

            var foo = app.ApplicationServices.GetRequiredService <StartupWithConfigureServices.IFoo>();

            Assert.True(foo.Invoked);
        }
예제 #11
0
        public void StartupClassCanHandleConfigureServicesThatReturnsNull()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
            var services = serviceCollection.BuildServiceProvider();

            var type    = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "WithNullConfigureServices");
            var startup = StartupLoader.LoadMethods(services, type, "WithNullConfigureServices");

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(new ServiceCollection());
            Assert.NotNull(app.ApplicationServices);
            startup.ConfigureDelegate(app);
            Assert.NotNull(app.ApplicationServices);
        }
예제 #12
0
 public static IServiceHostBuilder UseStartup(this IServiceHostBuilder hostBuilder, Type startupType)
 {
     return(hostBuilder
            .ConfigureServices(services =>
     {
         if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo()))
         {
             services.AddSingleton(typeof(IStartup), startupType);
         }
         else
         {
             services.AddSingleton(typeof(IStartup), sp =>
             {
                 return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, ""));
             });
         }
     }));
 }
예제 #13
0
        public void StartupClassAddsConfigureServicesToApplicationServices(string environment)
        {
            var services = new ServiceCollection().BuildServiceProvider();

            var type    = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", environment);
            var startup = StartupLoader.LoadMethods(services, type, environment);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(new ServiceCollection());
            startup.ConfigureDelegate(app);

            var options = app.ApplicationServices.GetRequiredService <IOptions <FakeOptions> >().Value;

            Assert.NotNull(options);
            Assert.True(options.Configured);
            Assert.Equal(environment, options.Environment);
        }
예제 #14
0
        public void StartupWithTwoConfiguresThrows()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddInstance <IFakeStartupCallback>(this);
            var services = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "TwoConfigures"
            };
            var loader = new StartupLoader(services, hostingEnv);
            var type   = loader.FindStartupType("Microsoft.AspNet.Hosting.Tests", diagnosticMessages);

            var ex = Assert.Throws <InvalidOperationException>(() => loader.LoadMethods(type, diagnosticMessages));

            Assert.Equal("Having multiple overloads of method 'Configure' is not supported.", ex.Message);
        }
예제 #15
0
        public void StartupWithNoConfigureThrows()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddInstance <IFakeStartupCallback>(this);
            var services = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "Boom"
            };
            var loader = new StartupLoader(services, hostingEnv);
            var type   = loader.FindStartupType("Microsoft.AspNet.Hosting.Tests", diagnosticMessages);

            var ex = Assert.Throws <InvalidOperationException>(() => loader.LoadMethods(type, diagnosticMessages));

            Assert.Equal("A method named 'ConfigureBoom' or 'Configure' in the type 'Microsoft.AspNet.Hosting.Fakes.StartupBoom' could not be found.", ex.Message);
        }
예제 #16
0
        public void StartupClassAddsConfigureServicesToApplicationServicesCaseInsensitive(string environment)
        {
            var services = new ServiceCollection()
                           .AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>()
                           .BuildServiceProvider();
            var type    = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", environment);
            var startup = StartupLoader.LoadMethods(services, type, environment);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(new ServiceCollection());
            startup.ConfigureDelegate(app); // By this not throwing, it found "ConfigureCaseInsensitive"

            var options = app.ApplicationServices.GetRequiredService <IOptions <FakeOptions> >().Value;

            Assert.NotNull(options);
            Assert.True(options.Configured);
            Assert.Equal("ConfigureCaseInsensitiveServices", options.Environment);
        }
예제 #17
0
        public void ConventionalStartupClass_ConfigureContainerFilters_WrapInRegistrationOrder()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <MyContainer>, MyContainerFactory>();
            serviceCollection.AddSingleton <IStartupConfigureContainerFilter <MyContainer> >(new TestConfigureContainerFilter(1, overrideAfterService: true));
            serviceCollection.AddSingleton <IStartupConfigureContainerFilter <MyContainer> >(new TestConfigureContainerFilter(2, overrideAfterService: true));
            var services = serviceCollection.BuildServiceProvider();

            var type    = typeof(ConfigureContainerStartupServicesFiltersStartup);
            var startup = StartupLoader.LoadMethods(services, type, "");

            var applicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            var before = applicationServices.GetRequiredService <ServiceBefore>();
            var after  = applicationServices.GetRequiredService <ServiceAfter>();

            Assert.Equal("ConfigureContainerFilter Before 1", before.Message);
            Assert.Equal("ConfigureContainerFilter After 1", after.Message);
        }
예제 #18
0
        public void ConventionalStartupClass_StartupServicesFilters_ThrowsIfStartupBuildsTheContainerAsync()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
            serviceCollection.AddSingleton <IStartupConfigureServicesFilter>(new TestStartupServicesFilter(1, overrideAfterService: false));
            var services = serviceCollection.BuildServiceProvider();

            var type    = typeof(IServiceProviderReturningStartupServicesFiltersStartup);
            var startup = StartupLoader.LoadMethods(services, type, "");

            var expectedMessage = $"A ConfigureServices method that returns an {nameof(IServiceProvider)} is " +
                                  $"not compatible with the use of one or more {nameof(IStartupConfigureServicesFilter)}. " +
                                  $"Use a void returning ConfigureServices method instead or a ConfigureContainer method.";

            var exception = Assert.Throws <InvalidOperationException>(() => startup.ConfigureServicesDelegate(serviceCollection));

            Assert.Equal(expectedMessage, exception.Message);
        }
예제 #19
0
        public void ConventionalStartupClass_StartupServiceFilters_MultipleStartupServiceFiltersRun()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
            serviceCollection.AddSingleton <IStartupConfigureServicesFilter>(new TestStartupServicesFilter(1, overrideAfterService: false));
            serviceCollection.AddSingleton <IStartupConfigureServicesFilter>(new TestStartupServicesFilter(2, overrideAfterService: true));
            var services = serviceCollection.BuildServiceProvider();

            var type    = typeof(VoidReturningStartupServicesFiltersStartup);
            var startup = StartupLoader.LoadMethods(services, type, "");

            var applicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            var before = applicationServices.GetRequiredService <ServiceBefore>();
            var after  = applicationServices.GetRequiredService <ServiceAfter>();

            Assert.Equal("StartupServicesFilter Before 1", before.Message);
            Assert.Equal("StartupServicesFilter After 2", after.Message);
        }
예제 #20
0
        public static IWorkerHostBuilder UseStartup(this IWorkerHostBuilder hostBuilder, Type startupType)
        {
            var startupAssemblyName = startupType.GetTypeInfo().Assembly.GetName().Name;

            if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo()))
            {
                hostBuilder.Services.AddSingleton(typeof(IStartup), startupType);
            }
            else
            {
                hostBuilder.Services.AddSingleton(typeof(IStartup), sp =>
                {
                    var hostingEnvironment = sp.GetRequiredService <IWorkerHostingEnvironment>();
                    return(new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName)));
                });
            }

            return(hostBuilder);
        }
예제 #21
0
 public static IGrpcHostBuilder UseStartup(this IGrpcHostBuilder builder, Type startupType)
 {
     return(builder.ConfigureServices(services =>
     {
         if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo()))
         {
             services.AddSingleton(typeof(IStartup), startupType);
         }
         else
         {
             services.AddSingleton(typeof(IStartup), sp =>
             {
                 var hostingEnvironment = sp.GetRequiredService <IHostingEnvironment>();
                 return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType,
                                                                             hostingEnvironment.EnvironmentName));
             });
         }
     }));
 }
예제 #22
0
        private void InitServerAndClient()
        {
            Server = new TestServer(WebHost.CreateDefaultBuilder()
                                    .ConfigureServices((context, services) => services.AddSingleton((IConfigurationRoot)context.Configuration))
                                    .ConfigureServices(services =>
            {
                services.AddSingleton <IStartup>(sp =>
                {
                    var startupMethods = StartupLoader.LoadMethods(sp, typeof(TStartup),
                                                                   Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));
                    return(new TestHostStartupWrapper(this, startupMethods));
                });
            })
                                    // Todo: remove once fixed (see https://github.com/aspnet/Hosting/issues/1137)
                                    .UseSetting(WebHostDefaults.ApplicationKey, typeof(TStartup).Assembly.FullName)
                                    );

            Client = Server.CreateClient();
        }
        public DelegatedStatelessWebServiceStartup(
            IServiceProvider provider,
            IHostEnvironment env,
            Action<IServiceCollection> configureServices)
        {
            _configureServices = configureServices;
            if (typeof(IStartup).IsAssignableFrom(typeof(TStartup)))
            {
                _startupImplementation = (IStartup) ActivatorUtilities.CreateInstance<TStartup>(provider)!;
            }
            else
            {
#if !NETCOREAPP3_1
                var methods = StartupLoader.LoadMethods(provider, typeof(TStartup), env.EnvironmentName);
                _startupImplementation = new ConventionBasedStartup(methods);
#else
                throw new InvalidOperationException($"Type '{typeof(TStartup).FullName}' must implement {typeof(IStartup).FullName}");
#endif
            }
        }
예제 #24
0
        public void StartupClassCanHandleConfigureServicesThatReturnsNull()
        {
            var serviceCollection = new ServiceCollection();
            var services          = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "WithNullConfigureServices"
            };
            var loader  = new StartupLoader(services, hostingEnv);
            var type    = loader.FindStartupType("Microsoft.AspNet.Hosting.Tests", diagnosticMessages);
            var startup = loader.LoadMethods(type, diagnosticMessages);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(new ServiceCollection());
            Assert.NotNull(app.ApplicationServices);
            startup.ConfigureDelegate(app);
            Assert.NotNull(app.ApplicationServices);
        }
예제 #25
0
        public void StartupLoaderCanLoadByTypeWithEnvironment()
        {
            var serviceCollection = new ServiceCollection();
            var services          = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "No"
            };
            var loader  = new StartupLoader(services, hostingEnv);
            var startup = loader.LoadMethods(typeof(TestStartup), diagnosticMessages);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);

            var ex = Assert.Throws <TargetInvocationException>(() => startup.ConfigureDelegate(app));

            Assert.IsAssignableFrom(typeof(InvalidOperationException), ex.InnerException);
        }
예제 #26
0
        /// <summary>
        /// Configures the host services with a Startup class
        /// </summary>
        /// <typeparam name ="TStartup">The type used to configure services</typeparam>
        /// <param name="hostBuilder">The <see cref="IXamarinHostBuilder"/> to configure.</param>
        /// <param name="startup">The instance of startup class to configure services with</param>
        /// <returns>The <see cref="IXamarinHostBuilder"/>.</returns>
        public static IXamarinHostBuilder UseStartup <TStartup>(this IXamarinHostBuilder hostBuilder, TStartup startup) where TStartup : class
        {
            var startupType = typeof(TStartup);

            return(hostBuilder
                   .ConfigureServices((context, services) =>
            {
                if (typeof(IXamarinStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo()))
                {
                    services.AddSingleton((IXamarinStartup)startup);
                }
                else
                {
                    services.AddSingleton <IXamarinStartup>(sp =>
                    {
                        var hostingEnvironment = sp.GetRequiredService <IXamarinHostEnvironment>();
                        return new XamarinStartup(StartupLoader.LoadMethods(startup, hostingEnvironment.EnvironmentName));
                    });
                }
            }));
        }
예제 #27
0
        public void ConventionalStartupClass_StartupServiceFilters_WrapsConfigureServicesMethod()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IServiceProviderFactory <IServiceCollection>, DefaultServiceProviderFactory>();
#pragma warning disable CS0612 // Type or member is obsolete
            serviceCollection.AddSingleton <IStartupConfigureServicesFilter>(new TestStartupServicesFilter(1, overrideAfterService: true));
            serviceCollection.AddSingleton <IStartupConfigureServicesFilter>(new TestStartupServicesFilter(2, overrideAfterService: true));
#pragma warning restore CS0612 // Type or member is obsolete
            var services = serviceCollection.BuildServiceProvider();

            var type    = typeof(VoidReturningStartupServicesFiltersStartup);
            var startup = StartupLoader.LoadMethods(services, type, "");

            var applicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            var before = applicationServices.GetRequiredService <ServiceBefore>();
            var after  = applicationServices.GetRequiredService <ServiceAfter>();

            Assert.Equal("StartupServicesFilter Before 1", before.Message);
            Assert.Equal("StartupServicesFilter After 1", after.Message);
        }
예제 #28
0
 public InternalVirtualHost(
     PathString appBase,
     List <IHostModule> modules)
 {
     _appBase    = appBase;
     Pages       = new ReadOnlyCollection <Page>(modules.SelectMany(x => x.Pages).ToList());
     _testServer = new TestServer(new WebHostBuilder()
                                  .UseSetting(WebHostDefaults.ApplicationKey, Assembly.GetEntryAssembly().GetName().Name)
                                  .ConfigureLogging(factory => {
         factory.AddConsole();
     })
                                  .ConfigureServices(services => {
         services.AddSingleton <Startup>();
         services.AddSingleton(modules);
         services.AddSingleton(typeof(IStartup), sp =>
         {
             var hostingEnvironment = sp.GetRequiredService <IHostingEnvironment>();
             return(new ConventionBasedStartup(StartupLoader.LoadMethods(sp, typeof(Startup), hostingEnvironment.EnvironmentName)));
         });
     }));
 }
예제 #29
0
        public void StartupClassMayHaveHostingServicesInjected()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddInstance <IFakeStartupCallback>(this);
            var services = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "WithServices"
            };
            var loader  = new StartupLoader(services, hostingEnv);
            var type    = loader.FindStartupType("Microsoft.AspNet.Hosting.Tests", diagnosticMessages);
            var startup = loader.LoadMethods(type, diagnosticMessages);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            startup.ConfigureDelegate(app);

            Assert.Equal(2, _configurationMethodCalledList.Count);
        }
예제 #30
0
        public void StartupClassWithConfigureServicesShouldMakeServiceAvailableInConfigure()
        {
            var serviceCollection = new ServiceCollection();
            var services          = serviceCollection.BuildServiceProvider();

            var diagnosticMessages = new List <string>();
            var hostingEnv         = new HostingEnvironment {
                EnvironmentName = "WithConfigureServices"
            };
            var loader  = new StartupLoader(services, hostingEnv);
            var type    = loader.FindStartupType("Microsoft.AspNet.Hosting.Tests", diagnosticMessages);
            var startup = loader.LoadMethods(type, diagnosticMessages);

            var app = new ApplicationBuilder(services);

            app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection);
            startup.ConfigureDelegate(app);

            var foo = app.ApplicationServices.GetRequiredService <StartupWithConfigureServices.IFoo>();

            Assert.True(foo.Invoked);
        }