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>
21 lines
585 B
C#
21 lines
585 B
C#
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);
|
|
}
|
|
}
|