58 references to TestDbContext
Aspire.MongoDB.EntityFrameworkCore.Tests (58)
AspireMongoDBEntityFrameworkCoreExtensionsTests.cs (32)
35builder.AddMongoDbContext<TestDbContext>("mongodb", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 38var context = host.Services.GetRequiredService<TestDbContext>(); 53builder.AddMongoDbContext<TestDbContext>("mongodb", databaseName: "explicitDb", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 56var context = host.Services.GetRequiredService<TestDbContext>(); 71builder.AddMongoDbContext<TestDbContext>("mongodb", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 74var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 88builder.AddMongoDbContext<TestDbContext>("mongodb","testdb", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 91var context = host.Services.GetRequiredService<TestDbContext>(); 106builder.AddMongoDbContext<TestDbContext>("mongodb","testdb", 111var context = host.Services.GetRequiredService<TestDbContext>(); 130builder.AddMongoDbContext<TestDbContext>("mongodb", "testdb", configureDbContextOptions: ConfigureDbContextOptionsBuilderForTesting); 133var context = host.Services.GetRequiredService<TestDbContext>(); 151builder.AddMongoDbContext<TestDbContext>("mongodb","testdb", configureDbContextOptions: optionsBuilder => 157var context = host.Services.GetRequiredService<TestDbContext>(); 188builder.AddMongoDbContext<TestDbContext>("mongodb","testdb"); 192var context = host.Services.GetRequiredService<TestDbContext>(); 220builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 224builder.Services.AddDbContextPool<TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 227var exception = Assert.Throws<InvalidOperationException>(() => builder.AddMongoDbContext<TestDbContext>("mongodb", "testdb")); 244builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 248builder.Services.AddDbContextPool<TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 251var exception = Record.Exception(() => builder.AddMongoDbContext<TestDbContext>("mongodb", "testdb")); 272builder.AddMongoDbContext<TestDbContext>(connectionName, DatabaseName ); 275builder.AddMongoDbContext<TestDbContext>(connectionName, databaseName, settings => 302builder.AddMongoDbContext<TestDbContext>(connectionName, databaseName, settings =>
ConformanceTests.cs (7)
15public class ConformanceTests : ConformanceTests<TestDbContext, MongoDBEntityFrameworkCoreSettings>, IClassFixture<MongoDbContainerFixture> 78=> builder.AddMongoDbContext<TestDbContext>(key ?? "mongodb","test_db" ,configure); 87protected override void TriggerActivity(TestDbContext service) 117IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 127TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
EnrichMongoDbTests.cs (16)
24builder.Services.AddDbContextPool<TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 25builder.EnrichMongoDbContext<TestDbContext>(configure); 33var exception = Assert.Throws<InvalidOperationException>(() => builder.EnrichMongoDbContext<TestDbContext>()); 42builder.Services.AddDbContext<TestDbContext>(options => options.UseMongoDB(ConnectionString, DatabaseName)); 44builder.EnrichMongoDbContext<TestDbContext>(); 57builder.Services.AddDbContextPool<ITestDbContext, TestDbContext>(optionsBuilder => 62builder.EnrichMongoDbContext<TestDbContext>(); 65var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 74builder.Services.AddDbContext<ITestDbContext, TestDbContext>(optionsBuilder => 79builder.EnrichMongoDbContext<TestDbContext>(); 81var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 86var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 99builder.Services.AddDbContextPool<TestDbContext>(optionsBuilder => 104builder.EnrichMongoDbContext<TestDbContext>();
TestDbContext.cs (3)
10public DbSet<TestDbContext.CatalogBrand> CatalogBrands { get; } 13public class TestDbContext(DbContextOptions<TestDbContext> options) : DbContext(options), ITestDbContext 15public DbContextOptions<TestDbContext> Options { get; } = options;