Anarchy.Toolkit.Testing.Db.Mysql
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Testing kit · Package catalog
MySQL integration-test helpers for the toolkit’s MySqlConnector persistence adapter.
dotnet add package Anarchy.Toolkit.Testing.Db.Mysql
- Use
MysqlHelperorSingletonMysqlHelperfor database fixtures andMysqlOptionsMapperfor options mapping. IMysqlAppSettingssupports settings-based fixtures; helpers also provide enum handlers and table cleanup.- Tests need a MySQL instance and an application schema. MySQL
TRUNCATEresets auto-increment and may fail for referenced tables.
When to use it
Use this package in integration tests that must verify actual MySQL SQL, mappings or transaction behavior. It creates toolkit persistence fixtures against a configured server; it does not start MySQL or create application tables.
How to use it
- Provision an isolated MySQL database and schema. Implement
IMysqlAppSettingson your test settings type; also implementIResilienceAppSettingswhen creating a resilience policy fixture. - Use
MysqlHelper.DbPolicyFixture<TAppSettings>()or pass a settings instance directly; useDbUnitOfWorkFixturefor unit-of-work tests. The generic overload reads embedded test settings from the settings type’s assembly. - Register enum handlers when needed, arrange data, execute the repository and assert results. Use the shared database cleanup helpers only on trusted test tables.
SingletonMysqlHelper can share a policy across tests; manage shared state and parallel cleanup carefully. Use a disposable test database, not production credentials.
See Infrastructure.Persistence.Db.Mysql, the MySQL notes and the testing conventions.
Releases
See the release notes for the complete release history.