Migrate database tests from SQL Server to SQLite#4820
Merged
rockfordlhotka merged 3 commits intoMarimerLLC:mainfrom Feb 14, 2026
Merged
Migrate database tests from SQL Server to SQLite#4820rockfordlhotka merged 3 commits intoMarimerLLC:mainfrom
rockfordlhotka merged 3 commits intoMarimerLLC:mainfrom
Conversation
Replace SQL Server LocalDB dependency with SQLite so database integration
tests can run in CI where no SQL Server instance is available.
Changes:
- Add SqliteTestDb.cs to create/manage a temporary SQLite database with
the same schema and seed data as the original LocalDB test database
- Replace Microsoft.Data.SqlClient with Microsoft.Data.Sqlite package
- Simplify WellKnownValues.cs to serve the SQLite connection string
- Initialize/cleanup SQLite database in AssemblyInitialize/Cleanup
- Remove #if DEBUG guards and [TestCategory("SkipOnCIServer")] attributes
from SafeDataReaderTests, DataPortalTests, and DataPortalExceptionTests
- Update exception message assertions for SQLite CHECK constraint errors
- Remove MDF/LDF file copy references from project file
https://claude.ai/code/session_0123tC2ciU58UgL8jR2d5PBt
d88cb56 to
a1d32e0
Compare
SQLite's SqliteConnection does not automatically enlist in ambient System.Transactions.TransactionScope the way SQL Server does. Replace the [Transactional(TransactionalTypes.TransactionScope)] attribute with an explicit SQLite transaction so the first INSERT is properly rolled back when the second INSERT fails the CHECK constraint. https://claude.ai/code/session_0123tC2ciU58UgL8jR2d5PBt
Microsoft.Data.Sqlite does not support System.Transactions.TransactionScope (EnlistTransaction throws NotSupportedException). Switch to System.Data.SQLite which properly enlists in ambient TransactionScope, so the [Transactional(TransactionalTypes.TransactionScope)] attribute test remains valid and the rollback behavior is tested end-to-end through CSLA. https://claude.ai/code/session_0123tC2ciU58UgL8jR2d5PBt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the CSLA test suite from using SQL Server (System.Data.SqlClient) to SQLite (Microsoft.Data.Sqlite), enabling tests to run without external database dependencies.
Key Changes
Replaced SQL Server with SQLite: Updated all test classes to use
SqliteConnectionandSqliteCommandinstead ofSqlConnectionandSqlCommandCreated SqliteTestDb utility class: New helper class that programmatically creates and manages an in-memory SQLite test database with schema and seed data mirroring the original SQL Server DataPortalTestDatabase
Updated WellKnownValues: Refactored to use the new SqliteTestDb instead of reading from app.config connection strings
Updated test infrastructure: Modified Startup.cs to initialize and cleanup the SQLite test database during assembly setup/teardown
Simplified test code: Removed verbose try-catch-finally blocks and leveraged C#
usingstatements for resource managementUpdated assertions: Modified schema validation assertions to use column names instead of ordinal indices for better maintainability
Updated exception handling: Changed expected exception types from
SqlExceptiontoSqliteExceptionUpdated CI workflow: Re-enabled test execution in GitHub Actions workflow
Project file updates: Replaced System.Data.SqlClient NuGet package reference with Microsoft.Data.Sqlite 6.0.0
Implementation Details
usingstatementshttps://claude.ai/code/session_0123tC2ciU58UgL8jR2d5PBt