A small Minimal API built with .NET 9 to manage a Todo list. Demonstrates a clean architecture using Dependency Injection, validation, pagination, and unit testing with xUnit & Moq. Designed to show how Minimal APIs simplify setup compared to traditional MVC Controllers, while keeping strong typing and testability.
- ⚡ CRUD endpoints (
GET,POST,PUT,PATCH,DELETE) - 🧠 In-memory repository with Dependency Injection
- 🔎 Search filter (
?search=) and pagination (pageIndex,pageSize) - 🧾 Validation: Title required, 1–100 chars
- 🧪 Unit tests with xUnit and Moq
- 💬 Proper HTTP responses (200, 201, 400, 404)
- 🚀 Swagger UI ready out of the box
MinimalTodos/
├─ MinimalTodos.sln
├─ MinimalTodos.API/
│ ├─ Domain/ # Models & DTOs
│ ├─ Endpoints/ # Minimal API routes
│ ├─ Extensions/ # App extensions (endpoint registration, DI helpers, etc.)
│ ├─ Repositories/ # ITodoRepository + InMemory repo
│ ├─ Validation/ # Custom validation
│ └─ Program.cs
└─ MinimalTodos.Tests/
├─ TodoRepositoryTests.cs
└─ TodoNotifierTests.cs
1) Build & Test
dotnet build
dotnet test2) Run the API
dotnet run --project MinimalTodos.API
# Open https://localhost:7026/swagger💡By default, the API runs on https://localhost:7026 (HTTPS) and http://localhost:5000 (HTTP). Swagger UI will open automatically at /swagger, allowing you to explore and test all endpoints interactively.
| Method | Endpoint | Description |
|---|---|---|
GET |
/todos |
List todos (with search & pagination) |
GET |
/todos/{id} |
Get a single todo |
POST |
/todos |
Create new todo |
PUT |
/todos/{id} |
Update todo |
PATCH |
/todos/{id}/toggle |
Toggle IsDone |
DELETE |
/todos/{id} |
Delete todo |
This project is licensed under the MIT License. See LICENSE for details.