public void InitializeDatabaseMustCallInitializeDatabaseActionWhenCalled()
        {
            int initializeDatabaseCalled = 0;
            StubDatabaseWebApplicationBuilder builder = new StubDatabaseWebApplicationBuilder();
            IServiceCollection collection             = new ServiceCollection().AddSingleton <FakeDbContext>();

            builder.DependenciesSetter = collection.BuildServiceProvider();
            builder.InitializeDatabase(_ => { ++initializeDatabaseCalled; });
            Assert.Equal(1, initializeDatabaseCalled);
        }
        public void ConfigureBootstrapMustCreateDatabase()
        {
            StubDatabaseWebApplicationBuilder builder = new StubDatabaseWebApplicationBuilder();
            IServiceCollection collection             = new ServiceCollection().AddSingleton <FakeDbContext>();
            ServiceProvider    provider = collection.BuildServiceProvider();

            builder.InvokeConfigureBootstrap(provider);
            FakeDbContext context = provider.GetRequiredService <FakeDbContext>();

            Assert.True((context.Database as DatabaseFacadeStub)?.Created);
        }
        public void ConfigureServicesMustConfigureDatabaseWhenCalled()
        {
            ServiceCollection services = new ServiceCollection();
            StubDatabaseWebApplicationBuilder builder = new StubDatabaseWebApplicationBuilder();

            builder.InvokeConfigureServices(services);
            Assert.Contains(services, x => x.ServiceType == typeof(FakeDbContext));
            ServiceProvider provider = services.BuildServiceProvider();

            provider.GetRequiredService <FakeDbContext>();
            DbContextOptions <FakeDbContext> options = builder.ContextOptions;

            Assert.Contains(options.Extensions, x => x is InMemoryOptionsExtension);
        }