test(unit): add handler unit tests for IBlogPostCacheService (#111) - #117
Conversation
🏗️ PR Added to Squad Triage QueueThis PR has been labeled with Next steps:
|
Test Results Summary203 tests 203 ✅ 14s ⏱️ Results for commit 05ac5fc. ♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## sprint/5-redis-caching #117 +/- ##
=========================================================
Coverage ? 70.38%
=========================================================
Files ? 43
Lines ? 672
Branches ? 111
=========================================================
Hits ? 473
Misses ? 147
Partials ? 52 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds new (currently TDD-red) unit-test specifications for the upcoming IBlogPostCacheService-based handler refactor, and reintroduces a stub Domain.Tests project to satisfy the repo’s pre-push Gate 3 expectations.
Changes:
- Add a new
tests/Unit.Testsproject with handler tests written against the futureIBlogPostCacheServicecontract (intentionally not wired intoMyBlog.slnxyet). - Add a stub
tests/Domain.Testsproject and register it inMyBlog.slnx. - Add supporting global usings for the new test projects.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit.Tests/Unit.Tests.csproj | New Unit test project targeting net10.0 with xUnit/NSubstitute/FluentAssertions references. |
| tests/Unit.Tests/GlobalUsings.cs | Adds global usings for Unit.Tests, including caching abstractions. |
| tests/Unit.Tests/Handlers/GetBlogPostsHandlerTests.cs | TDD-red tests describing expected caching delegation behavior for “get all” handler. |
| tests/Unit.Tests/Handlers/GetBlogPostByIdHandlerTests.cs | TDD-red tests describing expected caching delegation behavior for “get by id” query path. |
| tests/Unit.Tests/Handlers/CreateBlogPostHandlerTests.cs | TDD-red tests for create behavior + cache invalidation expectations. |
| tests/Unit.Tests/Handlers/EditBlogPostHandlerTests.cs | TDD-red tests for edit behavior, invalidation expectations, and concurrency error mapping. |
| tests/Unit.Tests/Handlers/DeleteBlogPostHandlerTests.cs | TDD-red tests for delete behavior, invalidation expectations, and concurrency error mapping. |
| tests/Domain.Tests/Domain.Tests.csproj | Stub Domain.Tests project (net10.0) to satisfy local Gate 3 requirements. |
| tests/Domain.Tests/GlobalUsings.cs | Minimal global usings for Domain.Tests stub. |
| MyBlog.slnx | Registers tests/Domain.Tests in the solution. |
| <Nullable>enable</Nullable> | ||
| <IsPackable>false</IsPackable> | ||
| <IsTestProject>true</IsTestProject> | ||
| <RootNamespace>MyBlog.Unit.Tests</RootNamespace> |
…111) Add Unit.Tests project with 5 handler test files covering the post-#110 IBlogPostCacheService contract. Tests are intentionally TDD-red and will not compile until Sam's #110 handler refactor merges IBlogPostCacheService into sprint/5-redis-caching. Also adds Domain.Tests stub (required by Gate 3) and registers it in MyBlog.slnx. Unit.Tests is NOT added to slnx to avoid Gate 2 build failure on this branch. - GetBlogPostsHandlerTests: delegates to cache, fetch-on-miss, exception→fail - GetBlogPostByIdHandlerTests: id forwarded, cache-miss invokes repo, null, exception - CreateBlogPostHandlerTests: success + InvalidateAllAsync, no InvalidateById, repo throws - EditBlogPostHandlerTests: success invalidates both keys, NotFound, concurrency - DeleteBlogPostHandlerTests: success invalidates both keys, repo throws, concurrency Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… slnx Sam's #115 (IBlogPostCacheService) and #118 (handler refactor) have merged. Changes: - Add Unit.Tests to MyBlog.slnx (safe now that IBlogPostCacheService exists) - Fix 3 NSubstitute mock setups: async lambda → ValueTask<T>(task) ctor (NSubstitute cannot convert async lambdas to ValueTask<T> return type) All 16 unit tests pass green across 5 handler test classes. Closes #111 Working as Gimli (Tester) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e48d72d to
05ac5fc
Compare
Closes #111
Working as Gimli (Tester)
Summary
Adds a new
Unit.Testsproject with TDD-red handler unit tests that document the expectedIBlogPostCacheServicecontract after Sam's #110 handler refactor. Tests are marked with the TDD-red pattern — they exist as executable specifications but will not compile onsprint/5-redis-cachinguntil #110 merges.Also adds the
Domain.Testsstub project (required by Gate 3 of the pre-push hook, removed in #104) and registers it inMyBlog.slnx.Why TDD-red?
IBlogPostCacheService(introduced in #109) is only available onsquad/109-cache-abstraction/squad/110-handler-refactor. The handler constructors onsprint/5still useIMemoryCache + IDistributedCache. AddingUnit.TeststoMyBlog.slnxwould fail Gate 2 on this branch, so the project is present on disk but not registered in the solution file until #110 merges.Changes
tests/Unit.Tests/Unit.Tests.csprojtests/Unit.Tests/GlobalUsings.csIBlogPostCacheServicetests/Unit.Tests/Handlers/GetBlogPostsHandlerTests.cstests/Unit.Tests/Handlers/GetBlogPostByIdHandlerTests.cstests/Unit.Tests/Handlers/CreateBlogPostHandlerTests.cstests/Unit.Tests/Handlers/EditBlogPostHandlerTests.cstests/Unit.Tests/Handlers/DeleteBlogPostHandlerTests.cstests/Domain.Tests/Domain.Tests.csprojtests/Domain.Tests/GlobalUsings.csMyBlog.slnxDomain.Testsonly (Unit.Tests excluded until #110 merges)Depends On
sprint/5-redis-cachingbase. Please have a squad member verify test contracts match Sam's #110 implementation before merging.