test: enforce layer dependency direction with NetArchTest (#12) #27

Merged
timothy merged 1 commits from foundations/12-arch-tests into main 2026-06-27 09:56:26 +02:00
Owner

Refs #12. New ErsatzTV.Architecture.Tests project that fails the build on layering violations, so the architecture can't erode one "just import it here" at a time.

Rules (reflect the intended layering + today's reference graph)

  • Core must not depend on Application / Infrastructure* / Scanner, nor on Microsoft.EntityFrameworkCore / Pomelo / Microsoft.Data.Sqlite / Dapper.
  • FFmpeg (lowest layer) must not depend on any other ErsatzTV layer.
  • Application must not depend on the concrete Infrastructure.Sqlite / Infrastructure.MySql providers (only the Infrastructure abstraction).
  • Infrastructure must not depend on Application or the concrete providers.

Notes

  • Uses NetArchTest.eNhancedEdition (maintained fork; the original NetArchTest.Rules is unmaintained since 2021 and its older Mono.Cecil doesn't reliably parse .NET 10 assemblies). Concrete reason for the deviation from the issue's literal suggestion.
  • Runs via the existing dotnet test in CI — no workflow change.
  • Verified non-vacuous: a temporary negative control (asserting the known-true Infrastructure → Core dependency is forbidden) failed as expected and listed the real offending types, proving the assemblies load and the rules have teeth. Removed before commit.

Verification

  • Arch tests: 5/5 pass. Full-solution Release build: 0 errors, 0 warnings.

Docs: the enforced layering will be written up in the contributors guide (#10, done last so it documents the now-enforced rules).

Refs #12. New `ErsatzTV.Architecture.Tests` project that fails the build on layering violations, so the architecture can't erode one "just import it here" at a time. ## Rules (reflect the intended layering + today's reference graph) - **Core** must not depend on `Application` / `Infrastructure*` / `Scanner`, nor on `Microsoft.EntityFrameworkCore` / `Pomelo` / `Microsoft.Data.Sqlite` / `Dapper`. - **FFmpeg** (lowest layer) must not depend on any other ErsatzTV layer. - **Application** must not depend on the **concrete** `Infrastructure.Sqlite` / `Infrastructure.MySql` providers (only the `Infrastructure` abstraction). - **Infrastructure** must not depend on `Application` or the concrete providers. ## Notes - Uses **NetArchTest.eNhancedEdition** (maintained fork; the original `NetArchTest.Rules` is unmaintained since 2021 and its older Mono.Cecil doesn't reliably parse .NET 10 assemblies). Concrete reason for the deviation from the issue's literal suggestion. - Runs via the existing `dotnet test` in CI — no workflow change. - **Verified non-vacuous**: a temporary negative control (asserting the *known-true* `Infrastructure → Core` dependency is forbidden) failed as expected and listed the real offending types, proving the assemblies load and the rules have teeth. Removed before commit. ## Verification - Arch tests: **5/5 pass**. Full-solution Release build: **0 errors, 0 warnings**. Docs: the enforced layering will be written up in the contributors guide (#10, done last so it documents the now-enforced rules).
timothy added 1 commit 2026-06-27 09:53:25 +02:00
test: enforce layer dependency direction with NetArchTest (#12)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 2m27s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 2m30s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 4m45s
c788ae57f1
Add ErsatzTV.Architecture.Tests asserting the solution's layering, so a
"just import it here" violation fails the build instead of eroding the
architecture over time:
- Core must not depend on Application/Infrastructure*/Scanner, nor on
  EF Core / Pomelo / Microsoft.Data.Sqlite / Dapper.
- FFmpeg (lowest layer) must not depend on any other ErsatzTV layer.
- Application must not depend on the concrete Infrastructure.Sqlite/.MySql
  providers (only the Infrastructure abstraction).
- Infrastructure must not depend on Application or the concrete providers.

Uses NetArchTest.eNhancedEdition — the maintained fork; the original
NetArchTest.Rules is unmaintained since 2021 and its older Mono.Cecil
doesn't reliably parse .NET 10 assemblies. Runs via the existing `dotnet
test` in CI. Rules verified with a negative control (a known-true
dependency asserted forbidden fails as expected — so they're not vacuous).

Refs #12

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
timothy merged commit c788ae57f1 into main 2026-06-27 09:56:26 +02:00
timothy deleted branch foundations/12-arch-tests 2026-06-27 09:56:26 +02:00
Sign in to join this conversation.