移除对账功能 后期从长计议
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m57s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s

This commit is contained in:
SunCheng
2026-01-27 15:29:25 +08:00
parent bade93ad57
commit 4aa7e82429
29 changed files with 716 additions and 328 deletions

View File

@@ -0,0 +1,58 @@
using FreeSql;
using Repository;
namespace WebApi.Test.Basic;
public class DatabaseTest : BaseTest, IDisposable
{
protected IFreeSql FreeSql { get; }
protected ITransactionRecordRepository Repository { get; }
public DatabaseTest()
{
FreeSql = new FreeSqlBuilder()
.UseConnectionString(DataType.Sqlite, "Data Source=:memory:")
.UseAutoSyncStructure(true)
.UseNoneCommandParameter(true)
.Build();
Repository = new TransactionRecordRepository(FreeSql);
}
public void Dispose()
{
FreeSql.Dispose();
}
protected TransactionRecord CreateTestRecord(
decimal amount,
TransactionType type = TransactionType.Expense,
DateTime? occurredAt = null,
string reason = "测试摘要",
string classify = "测试分类")
{
return new TransactionRecord
{
Amount = amount,
Type = type,
OccurredAt = occurredAt ?? DateTime.Now,
Reason = reason,
Classify = classify,
Card = "1234",
Balance = 1000,
EmailMessageId = 1,
ImportNo = Guid.NewGuid().ToString(),
ImportFrom = "测试"
};
}
protected TransactionRecord CreateExpense(decimal amount, DateTime? occurredAt = null, string reason = "支出", string classify = "餐饮")
{
return CreateTestRecord(-amount, TransactionType.Expense, occurredAt, reason, classify);
}
protected TransactionRecord CreateIncome(decimal amount, DateTime? occurredAt = null, string reason = "收入", string classify = "工资")
{
return CreateTestRecord(amount, TransactionType.Income, occurredAt, reason, classify);
}
}