6520ebf221
Self-hosted, plugin-extensible personal finance manager built with ASP.NET Core 9.0, Vue 3 + Vuetify 3, and PostgreSQL 17. Backend (8 .NET projects): - Core: 19 domain models, 6 enums, 14 DTOs, 12 service interfaces - Data: EF Core DbContext, 16 entity configurations, category seeder - API: 14 controllers, 15 services, JWT auth, SignalR, middleware - Plugins: Abstractions + OFX/CSV/QIF file parsers - Tests: 28 xUnit tests (fingerprinting, duplicate detection, parsers) Frontend (Vue 3 + Vuetify 3 + TypeScript): - 13 views, Pinia stores, Axios API services with JWT interceptors - Dashboard, accounts, transactions, categories, imports, and more Deployment: - Docker Compose (PostgreSQL 17 + .NET API + nginx frontend) - Auto-migration on startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using FluentAssertions;
|
|
using Purrse.Core.Helpers;
|
|
|
|
namespace Purrse.Tests.Helpers;
|
|
|
|
public class TransactionFingerprintTests
|
|
{
|
|
[Fact]
|
|
public void Generate_SameInputs_ReturnsSameHash()
|
|
{
|
|
var accountId = Guid.NewGuid();
|
|
var date = new DateTime(2024, 1, 15);
|
|
var amount = -42.50m;
|
|
var fitId = "FIT123";
|
|
|
|
var hash1 = TransactionFingerprint.Generate(accountId, date, amount, fitId);
|
|
var hash2 = TransactionFingerprint.Generate(accountId, date, amount, fitId);
|
|
|
|
hash1.Should().Be(hash2);
|
|
}
|
|
|
|
[Fact]
|
|
public void Generate_DifferentAmounts_ReturnsDifferentHash()
|
|
{
|
|
var accountId = Guid.NewGuid();
|
|
var date = new DateTime(2024, 1, 15);
|
|
|
|
var hash1 = TransactionFingerprint.Generate(accountId, date, -42.50m, "FIT123");
|
|
var hash2 = TransactionFingerprint.Generate(accountId, date, -42.51m, "FIT123");
|
|
|
|
hash1.Should().NotBe(hash2);
|
|
}
|
|
|
|
[Fact]
|
|
public void Generate_NullFitId_StillWorks()
|
|
{
|
|
var accountId = Guid.NewGuid();
|
|
var date = new DateTime(2024, 1, 15);
|
|
|
|
var hash = TransactionFingerprint.Generate(accountId, date, -42.50m, null);
|
|
|
|
hash.Should().NotBeNullOrEmpty();
|
|
hash.Should().HaveLength(64); // SHA256 hex = 64 chars
|
|
}
|
|
|
|
[Fact]
|
|
public void Generate_DifferentAccounts_ReturnsDifferentHash()
|
|
{
|
|
var date = new DateTime(2024, 1, 15);
|
|
|
|
var hash1 = TransactionFingerprint.Generate(Guid.NewGuid(), date, -42.50m, null);
|
|
var hash2 = TransactionFingerprint.Generate(Guid.NewGuid(), date, -42.50m, null);
|
|
|
|
hash1.Should().NotBe(hash2);
|
|
}
|
|
}
|