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/Architecture.Tests/CachingLayerTests.cs b/tests/Architecture.Tests/CachingLayerTests.cs new file mode 100644 index 00000000..ce42fb8d --- /dev/null +++ b/tests/Architecture.Tests/CachingLayerTests.cs @@ -0,0 +1,45 @@ +//======================================================= +//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; + + [Fact] + 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"); + } + + [Fact] + 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/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 + + + + + + + + + + + + + + + + + + + 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;