- Step-by-step prompts for solution skeleton, domain model, DbContext mappings, application services, UI shell/pages, PDF export, and tests/validation
2.6 KiB
2.6 KiB
description, agent
| description | agent |
|---|---|
| Create xUnit tests for transfer consistency, balance calculations, carryover logic, and PDF export totals | 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
TransferLinkexists 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
InMemoryor SQLite in-memory (Data Source=:memory:) for test database. - Wire up real service implementations against the test database.
- Use
FluentAssertionsfor readable assertions. - Arrange/Act/Assert pattern throughout.
Manual Verification Checklist (as code comments)
- Launch on Windows — app window opens with dashboard
- Launch on Linux — app window opens (requires WebKit2GTK)
- Create account → appears on dashboard with 0 balance
- Add year 2026 with carryover 500 → year appears in selector
- Add income/expense entries → table populates, balance updates
- Create transfer between accounts → both sides appear with transfer badge
- Export PDF → file saves, totals match on-screen values
- Delete transfer → both sides removed, balances correct