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:
20
MoneyMap.Tests/TestHelpers/DbContextHelper.cs
Normal file
20
MoneyMap.Tests/TestHelpers/DbContextHelper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user