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
-
objectDatabaseSeeder
- Implements
Constructors
DatabaseSeeder(IDataSeeder, SeedingSettings?, ILogger<DatabaseSeeder>?, TimeProvider?)
public DatabaseSeeder(IDataSeeder dataSeeder, SeedingSettings? settings = null, ILogger<DatabaseSeeder>? logger = null, TimeProvider? timeProvider = null)
Parameters
dataSeederIDataSeedersettingsSeedingSettingsloggerILogger<DatabaseSeeder>timeProviderTimeProvider
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
cancellationTokenCancellationTokenA 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
scenarioNamestringA name from
SeedScenarios.useMockHouseholdDataboolWhether to reseed via the mock-household path.
cancellationTokenCancellationTokenA 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
useMockHouseholdDataboolWhether 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
useMockHouseholdDataboolWhether to seed users corresponding to household mock data.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
userCountintNumber of users to create (default: 10).
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task