91 references to TestDbContext
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (91)
AspireEFPostgreSqlExtensionsTests.cs (30)
36builder.AddNpgsqlDbContext<TestDbContext>("npgsql", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 39var context = host.Services.GetRequiredService<TestDbContext>(); 52builder.AddNpgsqlDbContext<TestDbContext>("npgsql", 57var context = host.Services.GetRequiredService<TestDbContext>(); 74builder.AddNpgsqlDbContext<TestDbContext>("npgsql", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 77var context = host.Services.GetRequiredService<TestDbContext>(); 94builder.AddNpgsqlDbContext<TestDbContext>("npgsql", configureDbContextOptions: optionsBuilder => 104var context = host.Services.GetRequiredService<TestDbContext>(); 136builder.AddNpgsqlDbContext<TestDbContext>("npgsql", configureDbContextOptions: optionsBuilder => 146var context = host.Services.GetRequiredService<TestDbContext>(); 182builder.AddNpgsqlDbContext<TestDbContext>("npgsql", 187var context = host.Services.GetRequiredService<TestDbContext>(); 216builder.AddNpgsqlDbContext<TestDbContext>("npgsql", 221var context = host.Services.GetRequiredService<TestDbContext>(); 248builder.AddNpgsqlDbContext<TestDbContext>("npgsql"); 252var context = host.Services.GetRequiredService<TestDbContext>(); 274builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(options => options.UseNpgsql(ConnectionString)); 278builder.Services.AddDbContextPool<TestDbContext>(options => options.UseNpgsql(ConnectionString)); 281var exception = Assert.Throws<InvalidOperationException>(() => builder.AddNpgsqlDbContext<TestDbContext>("npgsql")); 297builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(options => options.UseNpgsql(ConnectionString)); 301builder.Services.AddDbContextPool<TestDbContext>(options => options.UseNpgsql(ConnectionString)); 304var exception = Record.Exception(() => builder.AddNpgsqlDbContext<TestDbContext>("npgsql"));
ConformanceTests.cs (7)
16public class ConformanceTests : ConformanceTests<TestDbContext, NpgsqlEntityFrameworkCorePostgreSQLSettings>, IClassFixture<PostgreSQLContainerFixture> 94=> builder.AddNpgsqlDbContext<TestDbContext>(key ?? "postgres", configure); 105protected override void TriggerActivity(TestDbContext service) 119IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 129TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
ConformanceTests_TypeSpecificConfig.cs (1)
19new($"Aspire:Npgsql:EntityFrameworkCore:PostgreSQL:{typeof(TestDbContext).Name}:ConnectionString", ConnectionString)
EnrichNpgsqlTests.cs (50)
28builder.Services.AddDbContextPool<TestDbContext>(options => options.UseNpgsql(ConnectionString)); 29builder.EnrichNpgsqlDbContext<TestDbContext>(configure); 37var exception = Assert.Throws<InvalidOperationException>(() => builder.EnrichNpgsqlDbContext<TestDbContext>()); 46builder.Services.AddDbContext<TestDbContext>(options => options.UseNpgsql(ConnectionString)); 48builder.EnrichNpgsqlDbContext<TestDbContext>(); 64builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 73builder.EnrichNpgsqlDbContext<TestDbContext>(); 76var context = host.Services.GetRequiredService<TestDbContext>(); 100builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 109builder.EnrichNpgsqlDbContext<TestDbContext>(settings => settings.CommandTimeout = 456); 112var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 121builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 127var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 130builder.EnrichNpgsqlDbContext<TestDbContext>(); 133var context = host.Services.GetRequiredService<TestDbContext>(); 157builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 166var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 169builder.EnrichNpgsqlDbContext<TestDbContext>(); 172var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 177var context = host.Services.GetRequiredService<TestDbContext>(); 201builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 210var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 213builder.EnrichNpgsqlDbContext<TestDbContext>(); 216var context = host.Services.GetRequiredService<TestDbContext>(); 237builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(optionsBuilder => 243builder.EnrichNpgsqlDbContext<TestDbContext>(); 246var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 255builder.Services.AddDbContext<ITestDbContext, TestDbContext>(optionsBuilder => 261builder.EnrichNpgsqlDbContext<TestDbContext>(); 263var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 268var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 277builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 283builder.EnrichNpgsqlDbContext<TestDbContext>(settings => settings.DisableRetry = true); 286var context = host.Services.GetRequiredService<TestDbContext>(); 306builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 312builder.EnrichNpgsqlDbContext<TestDbContext>(settings => settings.DisableRetry = false); 315var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 324builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 330builder.EnrichNpgsqlDbContext<TestDbContext>(settings => settings.DisableRetry = false); 333var context = host.Services.GetRequiredService<TestDbContext>(); 357builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 363builder.EnrichNpgsqlDbContext<TestDbContext>();
TestDbContext.cs (3)
10public DbSet<TestDbContext.CatalogBrand> CatalogBrands { get; } 15public TestDbContext(DbContextOptions<TestDbContext> options) : base(options) 20public DbContextOptions<TestDbContext> Options { get; }