From 2d9cd8c95bd933d316c261fca3bcfb459cb206ea Mon Sep 17 00:00:00 2001 From: Boromir Date: Thu, 23 Apr 2026 18:20:03 -0700 Subject: [PATCH 1/3] test(arch): add TDD-red CachingLayerTests and Domain.Tests GlobalUsings (#109) - CachingLayerTests skipped until #110 (handler refactor) merges - Domain.Tests/GlobalUsings.cs was untracked Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Architecture.Tests/CachingLayerTests.cs | 49 +++++++++++++++++++ tests/Domain.Tests/GlobalUsings.cs | 2 + 2 files changed, 51 insertions(+) create mode 100644 tests/Architecture.Tests/CachingLayerTests.cs create mode 100644 tests/Domain.Tests/GlobalUsings.cs diff --git a/tests/Architecture.Tests/CachingLayerTests.cs b/tests/Architecture.Tests/CachingLayerTests.cs new file mode 100644 index 00000000..12e1b58e --- /dev/null +++ b/tests/Architecture.Tests/CachingLayerTests.cs @@ -0,0 +1,49 @@ +//======================================================= +//Copyright (c) 2026. All rights reserved. +//File Name : CachingLayerTests.cs +//Company : mpaulosky +//Author : Matthew Paulosky +//Solution Name : MyBlog +//Project Name : Architecture.Tests +//======================================================= + +using MyBlog.Web.Features.BlogPosts.List; + +namespace MyBlog.Architecture.Tests; + +public class CachingLayerTests +{ + private static readonly System.Reflection.Assembly WebAssembly = typeof(GetBlogPostsQuery).Assembly; + + // TDD-red: handlers still inject IDistributedCache directly. + // Remove Skip once Sam's #110 (IBlogPostCacheService handler refactor) merges. + [Fact(Skip = "TDD-red: pending #110 — handlers must be refactored to use IBlogPostCacheService")] + public void Features_Should_Not_Reference_IDistributedCache_Directly() + { + var result = Types.InAssembly(WebAssembly) + .That() + .ResideInNamespace("MyBlog.Web.Features") + .ShouldNot() + .HaveDependencyOnAny("Microsoft.Extensions.Caching.Distributed") + .GetResult(); + + result.IsSuccessful.Should().BeTrue( + "VSA handlers must delegate caching to IBlogPostCacheService, not reference IDistributedCache directly"); + } + + // TDD-red: handlers still inject IMemoryCache directly. + // Remove Skip once Sam's #110 (IBlogPostCacheService handler refactor) merges. + [Fact(Skip = "TDD-red: pending #110 — handlers must be refactored to use IBlogPostCacheService")] + public void Features_Should_Not_Reference_IMemoryCache_Directly() + { + var result = Types.InAssembly(WebAssembly) + .That() + .ResideInNamespace("MyBlog.Web.Features") + .ShouldNot() + .HaveDependencyOnAny("Microsoft.Extensions.Caching.Memory") + .GetResult(); + + result.IsSuccessful.Should().BeTrue( + "VSA handlers must delegate caching to IBlogPostCacheService, not reference IMemoryCache directly"); + } +} diff --git a/tests/Domain.Tests/GlobalUsings.cs b/tests/Domain.Tests/GlobalUsings.cs new file mode 100644 index 00000000..ca05c4d1 --- /dev/null +++ b/tests/Domain.Tests/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using FluentAssertions; +global using MyBlog.Domain.Entities; From fefdee8e15454bdb7b7b0f56a5fbacd166c97ab0 Mon Sep 17 00:00:00 2001 From: Boromir Date: Thu, 23 Apr 2026 18:25:18 -0700 Subject: [PATCH 2/3] test(arch): add Domain.Tests stub project and register in solution (#113) - 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> --- MyBlog.slnx | 1 + tests/Domain.Tests/Domain.Tests.csproj | 28 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/Domain.Tests/Domain.Tests.csproj diff --git a/MyBlog.slnx b/MyBlog.slnx index e9922981..f8de783a 100644 --- a/MyBlog.slnx +++ b/MyBlog.slnx @@ -8,6 +8,7 @@ + diff --git a/tests/Domain.Tests/Domain.Tests.csproj b/tests/Domain.Tests/Domain.Tests.csproj new file mode 100644 index 00000000..4ef408b2 --- /dev/null +++ b/tests/Domain.Tests/Domain.Tests.csproj @@ -0,0 +1,28 @@ + + + + net10.0 + enable + enable + false + true + MyBlog.Domain.Tests + + + + + + + + + + + + + + + + + + + From da927483ed2969e184235cc5d07f1c0706878a69 Mon Sep 17 00:00:00 2001 From: Boromir Date: Thu, 23 Apr 2026 18:50:49 -0700 Subject: [PATCH 3/3] =?UTF-8?q?test(arch):=20activate=20caching=20layer=20?= =?UTF-8?q?tests=20=E2=80=94=20remove=20TDD-red=20Skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- tests/Architecture.Tests/CachingLayerTests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/Architecture.Tests/CachingLayerTests.cs b/tests/Architecture.Tests/CachingLayerTests.cs index 12e1b58e..ce42fb8d 100644 --- a/tests/Architecture.Tests/CachingLayerTests.cs +++ b/tests/Architecture.Tests/CachingLayerTests.cs @@ -15,9 +15,7 @@ public class CachingLayerTests { private static readonly System.Reflection.Assembly WebAssembly = typeof(GetBlogPostsQuery).Assembly; - // TDD-red: handlers still inject IDistributedCache directly. - // Remove Skip once Sam's #110 (IBlogPostCacheService handler refactor) merges. - [Fact(Skip = "TDD-red: pending #110 — handlers must be refactored to use IBlogPostCacheService")] + [Fact] public void Features_Should_Not_Reference_IDistributedCache_Directly() { var result = Types.InAssembly(WebAssembly) @@ -31,9 +29,7 @@ public void Features_Should_Not_Reference_IDistributedCache_Directly() "VSA handlers must delegate caching to IBlogPostCacheService, not reference IDistributedCache directly"); } - // TDD-red: handlers still inject IMemoryCache directly. - // Remove Skip once Sam's #110 (IBlogPostCacheService handler refactor) merges. - [Fact(Skip = "TDD-red: pending #110 — handlers must be refactored to use IBlogPostCacheService")] + [Fact] public void Features_Should_Not_Reference_IMemoryCache_Directly() { var result = Types.InAssembly(WebAssembly)