Class DbContextMockerExtensions
Entity Framework-specific FastMoq helpers.
Inheritance
DbContextMockerExtensions
Assembly: FastMoq.Database.dll
Syntax
public static class DbContextMockerExtensions
Methods
CreateLegacyDbContextMock(Type, MockBehavior, object?[])
Declaration
public static Mock? CreateLegacyDbContextMock(Type requestedType, MockBehavior behavior, object?[] constructorArgs)
Parameters
| Type |
Name |
Description |
| Type |
requestedType |
|
| MockBehavior |
behavior |
|
| object[] |
constructorArgs |
|
Returns
GetDbContextHandle<TContext>(Mocker, DbContextHandleOptions<TContext>?)
Creates or returns a DbContext test handle using the requested provisioning mode.
Declaration
public static DbContextHandle<TContext> GetDbContextHandle<TContext>(this Mocker mocker, DbContextHandleOptions<TContext>? options = null) where TContext : DbContext
Parameters
Returns
Type Parameters
| Name |
Description |
| TContext |
|
GetMockDbContext(Mocker, Type)
Creates or returns the tracked DbContext mock for the requested context type.
Declaration
public static Mock GetMockDbContext(this Mocker mocker, Type dbContextType)
Parameters
| Type |
Name |
Description |
| Mocker |
mocker |
|
| Type |
dbContextType |
|
Returns
GetMockDbContext<TContext>(Mocker)
Creates or returns the tracked DbContext mock for the requested context type.
Declaration
public static DbContextMock<TContext> GetMockDbContext<TContext>(this Mocker mocker) where TContext : DbContext
Parameters
| Type |
Name |
Description |
| Mocker |
mocker |
|
Returns
Type Parameters
| Name |
Description |
| TContext |
|
TryCreateManagedDbContextInstance(Mocker, Type, out object?)
Declaration
public static bool TryCreateManagedDbContextInstance(Mocker mocker, Type requestedType, out object? instance)
Parameters
Returns