Skip to content

test(arch): add TDD-red CachingLayerTests for IBlogPostCacheService boundary (#113) - #116

Merged
mpaulosky merged 4 commits into
sprint/5-redis-cachingfrom
squad/113-arch-caching-test
Apr 24, 2026
Merged

test(arch): add TDD-red CachingLayerTests for IBlogPostCacheService boundary (#113)#116
mpaulosky merged 4 commits into
sprint/5-redis-cachingfrom
squad/113-arch-caching-test

Conversation

@mpaulosky

@mpaulosky mpaulosky commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Closes #113

Working as Gimli (Tester)

What

Adds TDD-red architecture tests enforcing that VSA handlers in MyBlog.Web.Features must NOT directly reference IDistributedCache or IMemoryCache — they must delegate all caching to IBlogPostCacheService.

Tests are currently skipped (TDD-red) pending #110 (handler refactor). Remove the Skip attributes once #110 merges.

Changes

File Description
tests/Architecture.Tests/CachingLayerTests.cs 2 skipped arch tests: Features_Should_Not_Reference_IDistributedCache_Directly, Features_Should_Not_Reference_IMemoryCache_Directly
tests/Domain.Tests/GlobalUsings.cs Missing global usings file (pre-existing gap)
tests/Domain.Tests/Domain.Tests.csproj Stub project — unblocks Gate 3 of pre-push hook (project was deleted in #104 but hook still references it)
MyBlog.slnx Register Domain.Tests so Release build compiles it before --no-build test run

Activation

Remove the Skip attribute from both facts in CachingLayerTests.cs after #110 merges:

// Before (skipped):
[Fact(Skip = "TDD-red: pending #110 — handlers must be refactored to use IBlogPostCacheService")]

// After #110 merges:
[Fact]

Related

…gs (#109)

- CachingLayerTests skipped until #110 (handler refactor) merges
- Domain.Tests/GlobalUsings.cs was untracked

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 24, 2026 01:22
@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label Apr 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

)

- Add tests/Domain.Tests/Domain.Tests.csproj stub (unblocks Gate 3 of
  pre-push hook which references this project but it was deleted in #104)
- Register Domain.Tests in MyBlog.slnx so release build includes it

The CachingLayerTests (already committed) are [Fact(Skip)] TDD-red,
pending Sam's #110 handler refactor that adopts IBlogPostCacheService.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new architecture-test coverage intended to enforce the caching abstraction boundary in the Web “Features” layer (handlers must not depend directly on IDistributedCache/IMemoryCache, and should instead delegate caching to IBlogPostCacheService).

Changes:

  • Adds two (currently skipped) NetArchTest rules to detect direct dependencies on Microsoft.Extensions.Caching.Distributed and Microsoft.Extensions.Caching.Memory from MyBlog.Web.Features.
  • Adds a GlobalUsings.cs file under tests/Domain.Tests/.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/Architecture.Tests/CachingLayerTests.cs Introduces two skipped architecture tests intended to prevent direct cache dependencies in the Features layer.
tests/Domain.Tests/GlobalUsings.cs Adds global usings under a tests/Domain.Tests folder.

Comment on lines +39 to +44
var result = Types.InAssembly(WebAssembly)
.That()
.ResideInNamespace("MyBlog.Web.Features")
.ShouldNot()
.HaveDependencyOnAny("Microsoft.Extensions.Caching.Memory")
.GetResult();

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the test above: ResideInNamespace("MyBlog.Web.Features") won’t match MyBlog.Web.Features.* sub-namespaces, so this rule won’t apply to most handlers. Use ResideInNamespaceStartingWith("MyBlog.Web.Features") (or include sub-namespaces) and consider narrowing to handler types (e.g., HaveNameEndingWith("Handler")) to align with the stated goal.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
global using FluentAssertions;
global using MyBlog.Domain.Entities;

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is under tests/Domain.Tests/, but there is no Domain.Tests.csproj and MyBlog.slnx doesn’t include a Domain.Tests project, so these global usings won’t be compiled or used. Either add/restore a Domain.Tests test project and include it in the solution, or remove this folder/file to avoid orphaned, misleading code.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +28
var result = Types.InAssembly(WebAssembly)
.That()
.ResideInNamespace("MyBlog.Web.Features")
.ShouldNot()
.HaveDependencyOnAny("Microsoft.Extensions.Caching.Distributed")
.GetResult();

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResideInNamespace("MyBlog.Web.Features") only targets types in the exact namespace and will not include handlers under MyBlog.Web.Features.* (e.g., MyBlog.Web.Features.BlogPosts.List). Once the [Fact] is un-skipped, this test will likely pass even if handlers still depend on Microsoft.Extensions.Caching.Distributed. Consider switching to ResideInNamespaceStartingWith("MyBlog.Web.Features") (or the include-subnamespaces overload) and, if the intent is “VSA handlers”, also filter to HaveNameEndingWith("Handler") to avoid accidentally policing non-handler feature types.

Copilot uses AI. Check for mistakes.
@github-actions

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Test Results Summary

203 tests  +2   201 ✅ ±0   14s ⏱️ ±0s
  5 suites ±0     2 💤 +2 
  5 files   ±0     0 ❌ ±0 

Results for commit fefdee8. ± Comparison against base commit 7813f99.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (sprint/5-redis-caching@7409725). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                    @@
##             sprint/5-redis-caching     #116   +/-   ##
=========================================================
  Coverage                          ?   70.38%           
=========================================================
  Files                             ?       43           
  Lines                             ?      672           
  Branches                          ?      111           
=========================================================
  Hits                              ?      473           
  Misses                            ?      147           
  Partials                          ?       52           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Boromir and others added 2 commits April 23, 2026 18:50
Sam's #115 and #118 have merged, so handlers now use IBlogPostCacheService.
Both arch tests pass green:
  - Features_Should_Not_Reference_IDistributedCache_Directly
  - Features_Should_Not_Reference_IMemoryCache_Directly

Closes #113
Working as Gimli (Tester)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mpaulosky
mpaulosky merged commit 239da3b into sprint/5-redis-caching Apr 24, 2026
7 of 8 checks passed
@mpaulosky
mpaulosky deleted the squad/113-arch-caching-test branch April 24, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants