Table of Contents

Class DatabaseSeeder

Namespace
SEBT.Portal.Infrastructure.Seeding.Services
Assembly
SEBT.Portal.Infrastructure.Seeding.dll

Service for seeding the database with initial or test data.

public class DatabaseSeeder : IDatabaseSeeder
Inheritance
object
DatabaseSeeder
Implements

Constructors

DatabaseSeeder(IDataSeeder, SeedingSettings?, ILogger<DatabaseSeeder>?, TimeProvider?)

public DatabaseSeeder(IDataSeeder dataSeeder, SeedingSettings? settings = null, ILogger<DatabaseSeeder>? logger = null, TimeProvider? timeProvider = null)

Parameters

dataSeeder IDataSeeder
settings SeedingSettings
logger ILogger<DatabaseSeeder>
timeProvider TimeProvider

Methods

ClearSeededDataAsync(CancellationToken)

Clears seeded test data from the database. Deletes users matching the configured email pattern to avoid deleting production data.

public Task ClearSeededDataAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

ReseedUserScenarioAsync(string, bool, CancellationToken)

Deletes and recreates a single known seed scenario user so mutable E2E suites can restore a clean starting state without clearing the whole seed set.

public Task ReseedUserScenarioAsync(string scenarioName, bool useMockHouseholdData, CancellationToken cancellationToken = default)

Parameters

scenarioName string

A name from SeedScenarios.

useMockHouseholdData bool

Whether to reseed via the mock-household path.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

SeedTestUsers()

Synchronous version of SeedTestUsersAsync for use in UseSeeding callback.

public void SeedTestUsers()

SeedTestUsers(bool)

Synchronous version of SeedTestUsersAsync for use in UseSeeding callback.

public void SeedTestUsers(bool useMockHouseholdData)

Parameters

useMockHouseholdData bool

Whether to seed users corresponding to household mock data.

SeedTestUsersAsync(bool, CancellationToken)

Seeds the database with specific test users for development. If useMockHouseholdData is true, seeds users that correspond to household mock data.

public Task SeedTestUsersAsync(bool useMockHouseholdData, CancellationToken cancellationToken = default)

Parameters

useMockHouseholdData bool

Whether to seed users corresponding to household mock data.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

SeedTestUsersAsync(CancellationToken)

Seeds the database with specific test users for development.

public Task SeedTestUsersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

SeedUsersAsync(int, CancellationToken)

Seeds the database with sample users for development/testing.

public Task SeedUsersAsync(int userCount = 10, CancellationToken cancellationToken = default)

Parameters

userCount int

Number of users to create (default: 10).

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task