public async Task Test_StartupException() { bool isDisposed = false; AssemblyUtils.SetEntryAssembly(GetType().Assembly); var applicationConfig = ApplicationConfigBuilder .Create() .WithApplicationName(ApplicationName) .WithScanDirectories( TestAssemblyDirectories ) // Add all file starting with Dapplo and ending on .dll .WithAssemblyPatterns("Dapplo*") .BuildApplicationConfig(); using (var bootstrapper = new ApplicationBootstrapper(applicationConfig)) { bootstrapper.Configure(); // Makes the startup break bootstrapper.Builder.Register(context => true); bootstrapper.RegisterForDisposal(SimpleDisposable.Create(() => isDisposed = true)); // Initialize, so we can export Assert.True(await bootstrapper.InitializeAsync().ConfigureAwait(false), "Not initialized"); // Start the composition, and IStartupActions await Assert.ThrowsAsync <NotSupportedException>(async() => await bootstrapper.StartupAsync().ConfigureAwait(false)); } // Dispose automatically calls IShutdownActions Assert.True(isDisposed); }