{"id":1406,"date":"2025-11-25T15:45:54","date_gmt":"2025-11-25T15:45:54","guid":{"rendered":"https:\/\/oussamasaidi.com\/?p=1406"},"modified":"2025-12-20T11:14:43","modified_gmt":"2025-12-20T11:14:43","slug":"net-8-test-driven-design-architecture-7-proven-patterns-to-build-robust-maintainable-systems","status":"publish","type":"post","link":"https:\/\/oussamasaidi.com\/en\/net-8-test-driven-design-architecture-7-proven-patterns-to-build-robust-maintainable-systems\/","title":{"rendered":"Net 8 Test Driven Design Architecture 7 Proven Patterns to Build Robust, Maintainable Systems"},"content":{"rendered":"<h3 class=\"wp-block-heading\"><strong>Introduction to Test Driven Design \u2014 What this guide covers<\/strong><\/h3>\n\n\n\n<p>If you want a battle-tested approach to designing systems that are maintainable, testable, and production-ready, <strong>.Net 8 Test Driven Design Architecture<\/strong> combines the stability of .NET 8 with Test Driven Design discipline and modern architecture patterns. This guide gives patterns, pragmatic examples, and a checklist so you can start a new project or refactor an existing one with confidence.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Quick platform facts: .NET 8 is a Long-Term Support (LTS) release from Microsoft and includes platform improvements for ASP.NET Core, Blazor, performance, and tooling. Official downloads and SDKs are available from Microsoft\u2019s .NET download pages. <\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Why choose .NET 8 for Test Driven Design Architecture<\/strong><\/h3>\n\n\n\n<p><strong>Stability &amp; LTS:<\/strong> .NET 8 is officially supported as an LTS release, which makes it an excellent base for long-lived applications. This matters for enterprise-grade architecture decisions (security support, predictable update cadence).<\/p>\n\n\n\n<p><strong>Tooling &amp; productivity:<\/strong> Visual Studio (and VS Code) support .NET 8 tooling, plus CLI workflows (<code>dotnet<\/code>), hot-reload, and advanced test experiences that integrate with Test Driven Design . The .NET 8 runtime and SDK are continuously updated on Microsoft\u2019s download and release pages.<\/p>\n\n\n\n<p><strong>Ecosystem:<\/strong> EF Core, ASP.NET Core, Blazor, and the testing ecosystem (xUnit, NUnit, Moq, etc.) are all mature on .NET 8, reducing friction when designing test-first systems.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Core principles of Test Driven Design<\/strong><\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-test-workflow.png\" alt=\"Test Driven Design workflow\" class=\"wp-image-1416\" style=\"width:680px\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-test-workflow.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-test-workflow-300x300.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-test-workflow-150x150.png 150w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p>Test Driven Design is more than tests \u2014 it\u2019s a design feedback loop:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Red \u2014<\/strong> write a failing test expressing the requirement.<\/li>\n\n\n\n<li><strong>Green \u2014<\/strong> implement the simplest code to pass the test.<\/li>\n\n\n\n<li><strong>Refactor \u2014<\/strong> clean the code maintaining tests.<\/li>\n<\/ol>\n\n\n\n<p>Combine TDD with design techniques (<a href=\"https:\/\/oussamasaidi.com\/en\/solid-principles-in-c-explained-definitions-examples-best-practices\/\" target=\"_blank\" rel=\"noopener\" title=\"SOLID Principles in C# Explained: Definitions, Examples &amp; Best Practices\">SOLID<\/a>, Clean Architecture) so tests drive modular, decoupled code. Keep tests small, fast, and deterministic. Use the tests to document behavior and guide refactoring.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>High-level architecture patterns<\/strong><\/h3>\n\n\n\n<p><strong>Hexagonal (Ports &amp; Adapters)<\/strong> \u2014 keeps domain logic isolated behind ports. Tests target ports and core domain without touching infra concerns.<\/p>\n\n\n\n<p><strong>Clean Architecture<\/strong> \u2014 separates Presentation, Application, Domain, and Infrastructure layers. In TDD, start with domain tests, then application tests, pushing outwards into integration tests for adapters.<\/p>\n\n\n\n<p><strong>Modular Monolith<\/strong> \u2014 for many .NET teams, a well-structured monolith with strict module boundaries and test suites is preferable to premature microservices.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Test Driven Design<\/strong> <strong>Project structure and solution layout (practical)<\/strong><\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1.png\" alt=\"\" class=\"wp-image-1415\" style=\"width:680px\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1-300x300.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1-150x150.png 150w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1-768x768.png 768w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-1-12x12.png 12w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p>A common starting layout:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>src\/<\/code>\n<ul class=\"wp-block-list\">\n<li><code>MyApp.API<\/code> (ASP.NET Core minimal APIs \/ controllers)<\/li>\n\n\n\n<li><code>MyApp.Application<\/code> (use-cases, DTOs)<\/li>\n\n\n\n<li><code>MyApp.Domain<\/code> (entities, domain services)<\/li>\n\n\n\n<li><code>MyApp.Infrastructure<\/code> (EF Core, external integrations)<\/li>\n\n\n\n<li><code>MyApp.Shared<\/code> (shared types)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>tests\/<\/code>\n<ul class=\"wp-block-list\">\n<li><code>MyApp.Domain.Tests<\/code><\/li>\n\n\n\n<li><code>MyApp.Application.Tests<\/code><\/li>\n\n\n\n<li><code>MyApp.Integration.Tests<\/code> (uses TestServer or containerized DB)<\/li>\n\n\n\n<li><code>MyApp.Api.Tests<\/code> (contract \/ e2e)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Create test projects mirroring implementation projects. Keep tests isolated and fast: unit tests should not talk to databases.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Test Driven Design<\/strong> <strong>Dependency management &amp; DI in .NET 8<\/strong><\/h3>\n\n\n\n<p>Use the built-in DI container for standard cases; for advanced scenarios, use factories or the <code>IServiceProvider<\/code> only at composition roots. Register dependencies explicitly and keep lifetimes sensible (singleton for stateless services, scoped for request-bound, transient for short-lived). In tests, use constructor injection and test doubles to replace implementations.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Testing pyramid &amp; priority<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Unit tests (largest number):<\/strong> target domain logic and pure functions. They must be fast and deterministic.<\/li>\n\n\n\n<li><strong>Integration tests:<\/strong> verify behaviors between components (EF Core with InMemory or Testcontainers).<\/li>\n\n\n\n<li><strong>Contract tests:<\/strong> useful when your app integrates with other teams\/services.<\/li>\n\n\n\n<li><strong>End-to-end tests:<\/strong> fewer, but validate full flows; use them sparingly due to brittleness.<\/li>\n<\/ul>\n\n\n\n<p>For .NET 8, integration tests often use <code>WebApplicationFactory&lt;T&gt;<\/code> (for ASP.NET Core) or <code>TestServer<\/code> for in-process testing.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Test Driven Design<\/strong> <strong>workflows with .NET 8 tooling<\/strong><\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" width=\"1536\" height=\"1024\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-2.png\" alt=\"\" class=\"wp-image-1424\" style=\"width:680px\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-2.png 1536w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-2-300x200.png 300w\" sizes=\"(max-width: 1536px) 100vw, 1536px\" \/><\/figure>\n<\/div>\n\n\n<p>Recommended stack:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Test frameworks: <strong>xUnit<\/strong> (popular), NUnit, or MSTest.<\/li>\n\n\n\n<li>Mocking: <strong>Moq<\/strong>, <strong>NSubstitute<\/strong>, <strong>FakeItEasy<\/strong> depending on style.<\/li>\n\n\n\n<li><code>dotnet test<\/code> for CLI runs, and <code>dotnet watch test<\/code> for TDD loops.<\/li>\n\n\n\n<li>IDE: Visual Studio Live Unit Testing (if available) accelerates feedback.<\/li>\n<\/ul>\n\n\n\n<p>Example minimal TDD cycle in CLI:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dotnet new xunit -n MyApp.Domain.Tests\n# write failing test\ndotnet test\n# implement minimal code in src\ndotnet test\n# refactor\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Mocking &amp; seams<\/strong><\/h3>\n\n\n\n<p>Favor designing seams (abstractions) over complex mocking. For external systems, create small adapter interfaces (e.g., <code>IEmailSender<\/code>, <code>IClock<\/code>) and mock those. Use <code>Moq<\/code> or <code>NSubstitute<\/code> to verify interactions. For EF Core, prefer integration tests against a transient DB (SQLite in-memory or Testcontainers) to catch mapping\/SQL issues.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Designing for testability \u2014 code techniques<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Constructor injection<\/strong> for dependencies.<\/li>\n\n\n\n<li><strong>Small cohesive interfaces<\/strong> (Segregate responsibilities).<\/li>\n\n\n\n<li><strong>Avoid static state<\/strong> (or wrap it for testability).<\/li>\n\n\n\n<li><strong>Immutability<\/strong> where practical (value objects).<\/li>\n\n\n\n<li><strong>Pure functions<\/strong> for business rules \u2014 easy to unit test.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Domain logic &amp; persistence patterns<\/strong><\/h3>\n\n\n\n<p>Use Domain-Driven Design (DDD) concepts where appropriate:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Aggregates<\/strong> to maintain invariants.<\/li>\n\n\n\n<li><strong>Repositories<\/strong> with interface contracts \u2014 keep implementation in infra.<\/li>\n\n\n\n<li><strong>Unit of Work<\/strong> pattern when batching changes (EF Core DbContext often serves this role).<\/li>\n<\/ul>\n\n\n\n<p>Write domain tests first for invariants; write repository\/integration tests to ensure persistence behavior matches domain expectations.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>ASP.NET Core and Web APIs on .NET 8<\/strong><\/h3>\n\n\n\n<p>.NET 8 continues to mature minimal APIs and Blazor full-stack options. ASP.NET Core in .NET 8 introduces improvements such as streaming rendering and enhanced forms\/navigation in Blazor (see ASP.NET Core release notes). For API testing:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unit-test controllers\/handlers by testing minimal APIs&rsquo; delegate logic.<\/li>\n\n\n\n<li>Use <code>WebApplicationFactory&lt;T&gt;<\/code> for integration tests that boot the real pipeline.<\/li>\n\n\n\n<li>Pay attention to Kestrel configuration and server-level behavior in production. <\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Observability, CI\/CD &amp; secure pipelines<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logging: <code>ILogger&lt;T&gt;<\/code> everywhere; configure structured logging (Serilog or similar).<\/li>\n\n\n\n<li>Health checks: use ASP.NET Core health checks for liveness\/readiness.<\/li>\n\n\n\n<li>Metrics: integrate Prometheus exporters or Application Insights.<\/li>\n\n\n\n<li>CI: GitHub Actions or Azure DevOps; gate merges via <code>dotnet test<\/code>, static analysis, and code coverage thresholds.<\/li>\n<\/ul>\n\n\n\n<p>Set up pipelines to run fast unit tests on PRs and slower integration tests on scheduled builds or main-branch runs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Containerization &amp; performance<\/strong><\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8container-app.png\" alt=\"\" class=\"wp-image-1412\" style=\"width:680px\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8container-app.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8container-app-300x300.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8container-app-150x150.png 150w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p>.NET 8 continues to push smaller container images and better trimming\/AOT support (to reduce image size). Build multi-stage Dockerfiles and use runtime-only images for deployments. Profile with <code>dotnet-trace<\/code>, <code>dotnet-counters<\/code> and adjust GC settings for high-throughput services. Official .NET downloads and SDK updates are kept on Microsoft pages. <\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Migration tips from .NET 6\/7 to .NET 8<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Review breaking changes in official release notes and test your full suite. <\/li>\n\n\n\n<li>Adopt C# 12 features gradually; ensure toolchain support (compiler, analyzers).<\/li>\n\n\n\n<li>Update libraries and re-run integration tests to catch runtime issues.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Test Driven Design Anti-patterns &amp; common pitfalls<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Over-testing implementation details:<\/strong> prefer behavior tests.<\/li>\n\n\n\n<li><strong>Brittle integration tests:<\/strong> avoid relying on fragile external resources; use containers or harnesses.<\/li>\n\n\n\n<li><strong>Slow test suites:<\/strong> prioritize fast unit tests, parallelize test runs.<\/li>\n\n\n\n<li><strong>Test order dependence:<\/strong> ensure tests are isolated.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Checklist: Start a new .Net 8 Test Driven Design Architecture project<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create solution with clear project separation (<code>Domain<\/code>, <code>Application<\/code>, <code>Infrastructure<\/code>, <code>Api<\/code>).<\/li>\n\n\n\n<li>Add test projects per layer.<\/li>\n\n\n\n<li>Configure DI composition root in API project only.<\/li>\n\n\n\n<li>Add CI pipeline to run <code>dotnet restore<\/code>, <code>dotnet build<\/code>, <code>dotnet test<\/code>.<\/li>\n\n\n\n<li>Configure code coverage target and automated static analysis.<\/li>\n\n\n\n<li>Add health checks, structured logging, and observability hooks.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Frequently Asked Questions (FAQs)<\/strong><\/h2>\n\n\n\n<p><strong>Q1: Is .NET 8 an LTS release and is it safe for production?<\/strong><br>A1: Yes \u2014 .NET 8 is a Long-Term Support (LTS) release, making it suitable for production-grade systems that need predictable support windows. Official Microsoft docs confirm LTS status and the recommended download\/SDK pages. <\/p>\n\n\n\n<p><strong>Q2: Which test frameworks are recommended for TDD on .NET 8?<\/strong><br>A2: xUnit is widely used and integrates well with .NET toolchains; NUnit and MSTest are also valid. Pair them with mocking libraries like Moq, NSubstitute, or FakeItEasy depending on preference.<\/p>\n\n\n\n<p><strong>Q3: Should I unit test EF Core directly or use integration tests?<\/strong><br>A3: Prefer unit tests for domain logic. For EF Core behavior, use integration tests (SQLite in-memory or Testcontainers) to verify mappings and queries. This reduces false confidence from purely mocked EF tests.<\/p>\n\n\n\n<p><strong>Q4: How do I structure my solution for maintainability?<\/strong><br>A4: Use layer separation \u2014 <code>Domain<\/code>, <code>Application<\/code>, <code>Infrastructure<\/code>, <code>Api<\/code> \u2014 and keep tests mirrored by layer. Use small interfaces and keep composition at the API\/composition root.<\/p>\n\n\n\n<p><strong>Q5: What tools accelerate the TDD loop on .NET 8?<\/strong><br>A5: <code>dotnet watch test<\/code> for CLI rapid feedback, Visual Studio Live Unit Testing where available, and <code>dotnet<\/code> CLI tasks integrated into your editor are highly effective.<\/p>\n\n\n\n<p><strong>Q6: Any security notes specific to .NET 8?<\/strong><br>A6: Keep SDK\/runtime patched (Microsoft publishes updates regularly). Monitor release notes and security advisories for ASP.NET Core or Kestrel vulnerabilities and apply patches promptly.<\/p>\n\n\n\n<p><strong>Q7: Can I use minimal APIs with TDD?<\/strong><br>A7: Yes. Minimal APIs are testable: isolate business logic in service layers and unit test those. Use <code>WebApplicationFactory<\/code> for integration tests of the endpoint wiring.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Further reading \/ official references:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Microsoft: <em>What&rsquo;s new in .NET 8<\/em>. <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/core\/whats-new\/dotnet-8\/overview?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Learn<\/a><\/li>\n\n\n\n<li>Microsoft Dev Blog: <em>Announcing .NET 8<\/em>. <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-dotnet-8\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft for Developers<\/a><\/li>\n\n\n\n<li>Download and SDKs: Official .NET download page. <a href=\"https:\/\/dotnet.microsoft.com\/en-US\/download\/dotnet\/8.0?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft<\/a><\/li>\n<\/ul>\n\n\n\n<div class=\"buy-coffee-container\">\n<p style=\"text-align:center; color:#555; font-size:14px;\">\n  If this article helped you, consider supporting my work.\n<\/p>\n  <a\n    href=\"https:\/\/buymeacoffee.com\/oussamasaii\"\n    target=\"_blank\"\n    rel=\"noopener noreferrer\"\n    class=\"buy-coffee-button\"\n  >\n    &#x2615; Buy me a coffee\n  <\/a>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Introduction to Test Driven Design \u2014 What this guide covers If you want a battle-tested approach to designing systems that&#8230; <\/p>\n<div class=\"art-el-more\"><a href=\"https:\/\/oussamasaidi.com\/en\/net-8-test-driven-design-architecture-7-proven-patterns-to-build-robust-maintainable-systems\/\" class=\"art-link art-color-link art-w-chevron\">Read more<\/a><\/div>","protected":false},"author":1,"featured_media":1423,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[40,68,45,41,56,17,85,84,279,98,91,61],"tags":[47,48,49,54,97,53],"ppma_author":[286],"class_list":["post-1406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-netcore","category-api","category-asp-net","category-c","category-c-2","category-design","category-docker","category-ef-core","category-en","category-solid","category-unit-test","category-web-api","tag-net-core","tag-asp-net","tag-c-sharp","tag-c","tag-clean-code","tag-dot-net-core"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/dot-net-8-tdd-architecture-article-cover.png","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1714,"url":"https:\/\/oussamasaidi.com\/en\/https-oussamasaidi-com-restful-api-mastery-best-practices-with-asp-net-core-part-2\/","url_meta":{"origin":1406,"position":0},"title":"RESTful API best practices\u00a0with ASP.NET Core Part 2","author":"Saidi Oussama","date":"December 20, 2025","format":false,"excerpt":"Testing, Performance, Security, Microservices & Deployment Introduction: From Solid Foundations to Production Excellence In Part 1 of RESTful API Mastery, we established the architectural and technical foundations required to build reliable, evolvable RESTful APIs with ASP.NET Core. However, a well-designed API only becomes truly valuable when it is tested, observable,\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":988,"url":"https:\/\/oussamasaidi.com\/en\/domain-driven-design-clean-architecture-for-dot-net-core\/","url_meta":{"origin":1406,"position":1},"title":".Net 8 Domain Driven Design l&rsquo;Architecture Propre et simple","author":"Saidi Oussama","date":"April 4, 2025","format":false,"excerpt":"Introduction Dans le d\u00e9veloppement d'applications .NET Core robustes et maintenables, l'adoption d'une architecture propre (Clean Architecture) combin\u00e9e au Domain Driven Design (DDD) repr\u00e9sente une approche puissante. Ce guide complet vous pr\u00e9sente une impl\u00e9mentation structur\u00e9e, parfaite pour vos projets d'entreprise. Dans cet article Pourquoi Choisir cette Architecture Pour Domain Driven Design\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/ddd-net-corepng.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/ddd-net-corepng.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/ddd-net-corepng.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/ddd-net-corepng.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1639,"url":"https:\/\/oussamasaidi.com\/en\/restful-api-mastery-best-practices-with-asp-net-core\/","url_meta":{"origin":1406,"position":2},"title":"RESTful API Best Practices with ASP.NET Core","author":"Saidi Oussama","date":"December 16, 2025","format":false,"excerpt":"Professional Best Practices, Versioning Strategies & Advanced Serialization (Part 1) In this blog Introduction: Building Enterprise-Grade RESTful APIs with ASP.NET Core1. RESTful APIs in the Modern ASP.NET Core EcosystemWhy REST Still Dominates2. REST Architectural Constraints Every ASP.NET Core API Must EnforceClient\u2013Server SeparationStatelessnessUniform Interface3. Establishing a Clean and Scalable ASP.NET Core\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1325,"url":"https:\/\/oussamasaidi.com\/en\/building-professional-modern-api-documentation-in-net-core-with-scalar\/","url_meta":{"origin":1406,"position":3},"title":"Building Professional, Modern API Documentation in .NET Core with Scalar","author":"Saidi Oussama","date":"November 19, 2025","format":false,"excerpt":"Introduction In today\u2019s software ecosystem, APIs are everywhere. Whether you are building a mobile application, a microservices architecture, or an internal company platform, your API is often the backbone of the system. But even the best API becomes useless if developers cannot understand how to consume it. This is why\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"Building Professional, Modern API Documentation in .NET Core with Scalar","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":981,"url":"https:\/\/oussamasaidi.com\/en\/net-8-testing-libraries-complete-guide-for-developers\/","url_meta":{"origin":1406,"position":4},"title":"Best .NET 8 Testing Libraries: The Complete Guide for Developers","author":"Saidi Oussama","date":"December 15, 2025","format":false,"excerpt":"IntroductionWhy Testing Matters More Than Ever in .NET 8Types of Tests in .NET ApplicationsUnit TestsIntegration TestsEnd-to-End (E2E) Tests1. xUnit \u2013 The Most Popular .NET Testing FrameworkWhy xUnit Is a Top ChoiceInstalling xUnit in .NET 8Writing Your First xUnit TestWhy xUnit Works Well for Professionals2. NUnit \u2013 A Mature and Feature-Rich\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"Best .NET 8 Testing Libraries","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/best-dot-net-8-testing-libraries.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1254,"url":"https:\/\/oussamasaidi.com\/en\/how-to-build-an-idempotent-api-with-net-9-ef-core-9-and-polly-v8\/","url_meta":{"origin":1406,"position":5},"title":"How to Build an Idempotent API with .NET 9, EF Core 9 and Polly v8","author":"Saidi Oussama","date":"November 6, 2025","format":false,"excerpt":"Introduction Have you ever hit \u201cPay\u201d on a checkout page, the page froze, and you clicked again \u2014 only to be charged twice?That\u2019s exactly what idempotency prevents. In distributed and cloud-native architectures, duplicate requests happen often: client-side retries (mobile poor signal), API Gateway or load-balancer retries, users refreshing a browser\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"authors":[{"term_id":286,"user_id":1,"is_guest":0,"slug":"oussama_sa","display_name":"Saidi Oussama","avatar_url":{"url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg","url2x":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg"},"author_category":"1","first_name":"Oussama","last_name":"SAIDI","user_url":"https:\/\/oussamasaidi.com","job_title":"Senior Fullstack .NET Developer","description":"I\u2019m a Senior Fullstack .NET Developer specializing in building scalable, high-performance web applications with .NET, C#, and modern frontend frameworks like React.js. I\u2019m passionate about clean architecture, automated testing, and sharing knowledge through blogs and tutorials."}],"_links":{"self":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/comments?post=1406"}],"version-history":[{"count":99,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"predecessor-version":[{"id":1708,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1406\/revisions\/1708"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media\/1423"}],"wp:attachment":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media?parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/categories?post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/tags?post=1406"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/ppma_author?post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}