Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MyBlog.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Folder Name="/tests/">
<Project Path="tests/AppHost.Tests/AppHost.Tests.csproj" />
<Project Path="tests/Architecture.Tests/Architecture.Tests.csproj" />
<Project Path="tests/Domain.Tests/Domain.Tests.csproj" />
<Project Path="tests/Web.Tests/Web.Tests.csproj" />
<Project Path="tests/Web.Tests.Bunit/Web.Tests.Bunit.csproj" />
<Project Path="tests/Web.Tests.Integration/Web.Tests.Integration.csproj" />
Expand Down
45 changes: 45 additions & 0 deletions tests/Architecture.Tests/CachingLayerTests.cs
Original file line number Diff line number Diff line change
@@ -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();
Comment on lines +21 to +26

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.

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();
Comment on lines +35 to +40

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.

result.IsSuccessful.Should().BeTrue(
"VSA handlers must delegate caching to IBlogPostCacheService, not reference IMemoryCache directly");
}
}
28 changes: 28 additions & 0 deletions tests/Domain.Tests/Domain.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>MyBlog.Domain.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="FluentAssertions"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit"/>
<PackageReference Include="xunit.runner.visualstudio"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Domain\Domain.csproj"/>
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions tests/Domain.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using FluentAssertions;
global using MyBlog.Domain.Entities;
Comment on lines +1 to +2

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.
Loading