测试覆盖率
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 27s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
SunCheng
2026-01-28 17:00:58 +08:00
parent 3ed9cf5ebd
commit e93c3d6bae
30 changed files with 2492 additions and 227 deletions

View File

@@ -1,58 +0,0 @@
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);
}
}