| name | tdd-dotnet |
| description | Implement a .NET feature using strict Red-Green-Refactor TDD with xUnit, FluentAssertions, and Moq for PlaylistMiner backend. |
TDD Feature Implementation (.NET)
Implement the requested feature using strict Red-Green-Refactor TDD.
Step 1: Red — Write Failing Tests
- Create test class in
tests/PlaylistMiner.UnitTests/ matching the source file path
- Name tests:
Test_MethodName_Scenario_ExpectedResult
- Use FluentAssertions:
.Should().Be(), .Should().Contain(), .Should().Throw<>()
- Use Moq for dependencies:
var mock = new Mock<IService>()
- Follow Arrange-Act-Assert pattern
- Run
dotnet test — confirm tests FAIL
Step 2: Green — Minimal Implementation
- Write the minimum code to make tests pass
- No refactoring, no optimization, no extras
- Run
dotnet test — confirm tests PASS
Step 3: Refactor
- Clean up implementation keeping tests green
- Extract interfaces, simplify, reduce duplication
- Run
dotnet test — confirm tests still PASS
Rules
- NEVER write implementation before the test
- All async methods accept CancellationToken
- Return DTOs from Core project, never EF entities
- Use
[Category("Unit")] for unit, [Category("Integration")] for integration tests
- Integration tests use Testcontainers with real PostgreSQL