Skip to content

refactor: simplify key parsing, naming limits and test setup - #50

Merged
giammin merged 1 commit into
mainfrom
refactor/simplify-codebase
Oct 22, 2026
Merged

giammin merged 1 commit into
mainfrom
refactor/simplify-codebase

Conversation

@giammin

@giammin giammin commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Code-quality cleanup of the whole codebase (reuse, simplification, efficiency, altitude). No public API or runtime behavior change.

Source

  • StorageWrapper and DeletableStorageWrapper share the stored-key parsing loop through a ParseKeys iterator; TryParseKey is now private.
  • Remove the DeletableStorageWrapper constructor guard: it repeated the check that PersistKeysToStorage already makes before choosing the wrapper.
  • SQL Server: derive MaxTableNameLength from the index name pattern (GetIndexName) instead of the hand-counted MaxSchemaNameLength - 16. The limit is still 112.

Tests

  • One database container per provider for the whole assembly (xUnit v3 [assembly: AssemblyFixture]) instead of one per test class. This is safe because Respawn captures its table list at fixture start, and the end-to-end tests use their own tables.
  • The PostgreSQL repository tests reuse the existing CreateSut and CountRows helpers and a new NewTableName helper.
  • Share KeyMaterial through TestConstants, remove the unused TestConstants.Xml, and use the capturing logger factory throughout StorageWrapperTests.
  • Drop two tests whose cases are covered elsewhere, and merge the two UseDapperDataProtection tests into a [Theory].
  • TargetFrameworks -> TargetFramework; remove the duplicate xunit.runner.visualstudio metadata from the test csproj.
  • AGENTS.md: describe the assembly fixtures.

Verification

  • dotnet build -c Release: 0 warnings, 0 errors.
  • dotnet test --no-build -c Release: 156/156 passed.

Not done (out of scope)

  • Shared provider registration code and a shared GetIds helper in the Dapper package: this needs either new public API or InternalsVisibleTo across separately versioned packages.
  • A shared abstract base for the SQL Server/PostgreSQL repository tests: worth a separate PR.

- Share the stored-key parsing loop between StorageWrapper and
  DeletableStorageWrapper through a ParseKeys iterator, and drop the
  DeletableStorageWrapper constructor guard that repeated the check made
  by PersistKeysToStorage.
- Derive the SQL Server maximum table name length from the index name
  pattern instead of a hand-counted constant.
- Start one database container per provider for the whole test assembly
  (xUnit v3 assembly fixtures) instead of one per test class.
- Reuse the existing helpers in the PostgreSQL repository tests, share
  the key material constant, drop unused and duplicated tests, and remove
  redundant test build settings.
@giammin
giammin merged commit 2bdc4fe into main Oct 22, 2026
1 check passed
giammin added a commit that referenced this pull request Oct 22, 2026
xUnit v3 starts assembly fixtures on every run, so since #50 even a
filtered unit-only run started the SQL Server and PostgreSQL containers
and required Docker. Share each container through a collection fixture
instead: it still starts once per provider, but only when that
provider's tests run.

Move the unique table name helper to the fixtures, so the four test
classes no longer keep their own copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant