Table of Contents

Class DatabaseLifecycleFixture<TEntryPoint, TContext>

Namespace
FEFF.TestFixtures.AspNetCore.EF
Assembly
FEFF.TestFixtures.AspNetCore.EF.dll

A fixture that manages Entity Framework Core database creation and deletion for the lifetime of a test scope. The database is deleted on DisposeAsync().

public sealed class DatabaseLifecycleFixture<TEntryPoint, TContext> : IAsyncDisposable, IDatabaseLifecycleFixture<TContext>, IDatabaseLifecycleFixture where TEntryPoint : class where TContext : DbContext

Type Parameters

TEntryPoint

The application entry point type.

TContext

The DbContext type to manage.

Inheritance
DatabaseLifecycleFixture<TEntryPoint, TContext>
Implements
Inherited Members
Extension Methods

Remarks

Note: EnsureDeleted may fail for admin databases. Consider using TmpDbNameFixture for such cases.

Constructors

DatabaseLifecycleFixture(AppManagerFixture<TEntryPoint>, AppServicesFixture<TEntryPoint>)

Creates a new database lifecycle management fixture.

public DatabaseLifecycleFixture(AppManagerFixture<TEntryPoint> app, AppServicesFixture<TEntryPoint> services)

Parameters

app AppManagerFixture<TEntryPoint>

The application manager fixture.

services AppServicesFixture<TEntryPoint>

The application services fixture.

Properties

LazyDbContext

Gets the TContext instance resolved from the service provider.

public TContext LazyDbContext { get; }

Property Value

TContext

Remarks

Accessing this property starts the application under test if not already running.

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.