Files
duempelkas/.github/prompts/07-tests-and-validation.prompt.md
troogs e589cc170a Add GitHub Copilot prompt files
- Step-by-step prompts for solution skeleton, domain model,
  DbContext mappings, application services, UI shell/pages,
  PDF export, and tests/validation
2026-03-31 17:12:35 +02:00

81 lines
2.6 KiB
Markdown

---
description: "Create xUnit tests for transfer consistency, balance calculations, carryover logic, and PDF export totals"
agent: "agent"
---
# Step 7: Tests & Validation
Create tests in `tests/Duempelkas.Tests/`.
## Test 1: Transfer Consistency (`TransferServiceTests.cs`)
### Scenario: CreateTransfer_CreatesLinkedExpenseAndIncome
Given:
- Account A and Account B exist
- Both have AccountYear for 2026 with OpeningBalance = 0
When:
- A transfer of 100.00 EUR is created from A/2026 to B/2026 with title "Test Transfer"
Then:
- Exactly 2 entries are created in the database
- Entry on A is `EntryType.Expense`, amount = 100.00
- Entry on B is `EntryType.Income`, amount = 100.00
- Both entries share the same date and title
- Exactly 1 `TransferLink` exists linking the two entries
- Account A total balance = -100.00
- Account B total balance = +100.00
### Scenario: DeleteTransfer_RemovesBothSides
Given:
- A transfer exists between A and B
When:
- The source entry is deleted via `IEntryService.DeleteEntryAsync`
Then:
- Both entries are removed
- The TransferLink is removed
- Account A and B balances return to 0
## Test 2: Yearly Statement Calculation (`YearlyStatementCalculationTests.cs`)
### Scenario: YearlySummary_CalculatesCorrectTotals
Given:
- Account with Year 2026, OpeningBalance = 500.00
- Entries: Income 800.00, Income 400.00, Expense 200.00, Expense 250.00
Then:
- TotalIncome = 1200.00
- TotalExpense = 450.00
- YearlyMovement = 750.00
- ClosingBalance = 1250.00
### Scenario: YearlySummary_IncludesTransfersCorrectly
Given:
- Account A, Year 2026, OpeningBalance = 500.00
- Income entry: 1000.00
- Transfer out to Account B: 300.00 (creates Expense entry on A)
Then:
- A's TotalIncome = 1000.00
- A's TotalExpense = 300.00
- A's YearlyMovement = 700.00
- A's ClosingBalance = 1200.00
## Test Setup
- Use EF Core `InMemory` or SQLite in-memory (`Data Source=:memory:`) for test database.
- Wire up real service implementations against the test database.
- Use `FluentAssertions` for readable assertions.
- Arrange/Act/Assert pattern throughout.
## Manual Verification Checklist (as code comments)
1. Launch on Windows — app window opens with dashboard
2. Launch on Linux — app window opens (requires WebKit2GTK)
3. Create account → appears on dashboard with 0 balance
4. Add year 2026 with carryover 500 → year appears in selector
5. Add income/expense entries → table populates, balance updates
6. Create transfer between accounts → both sides appear with transfer badge
7. Export PDF → file saves, totals match on-screen values
8. Delete transfer → both sides removed, balances correct