Test: add comprehensive unit test project for services

Add MoneyMap.Tests project with xUnit tests for all new services:

- AccountServiceTests: Account retrieval, stats, validation, deletion
- CardServiceTests: Card retrieval, stats, validation, deletion
- MerchantServiceTests: Merchant CRUD operations
- ReferenceDataServiceTests: Reference data retrieval
- TransactionServiceTests: Duplicate detection, retrieval, deletion
- TransactionStatisticsServiceTests: Statistics calculations
- ReceiptMatchingServiceTests: Receipt-to-transaction matching logic
- DbContextHelper: In-memory database context factory for test isolation

Uses xUnit, Moq, and EF Core InMemory database. Solution file updated to include test project.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
AJ
2025-10-26 00:01:28 -04:00
parent f8bb5d5a82
commit af4a638b81
10 changed files with 1679 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using MoneyMap.Data;
namespace MoneyMap.Tests.TestHelpers;
public static class DbContextHelper
{
/// <summary>
/// Creates an in-memory database context for testing.
/// Each call creates a unique database to ensure test isolation.
/// </summary>
public static MoneyMapContext CreateInMemoryContext()
{
var options = new DbContextOptionsBuilder<MoneyMapContext>()
.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
.Options;
return new MoneyMapContext(options);
}
}