fix
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 3s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 3s
This commit is contained in:
@@ -93,7 +93,7 @@ public class TransactionStatisticsServiceTest : BaseTest
|
||||
// Mock Logic: filter by year (Arg[0]) and month (Arg[1]) and type (Arg[4]) if provided
|
||||
_transactionRepository.QueryAsync(
|
||||
Arg.Any<int?>(), Arg.Any<int?>(), Arg.Any<DateTime?>(), Arg.Any<DateTime?>(), Arg.Any<TransactionType?>(), Arg.Any<string[]>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<int>(), Arg.Any<int>(), Arg.Any<bool>()
|
||||
).Returns(callInfo =>
|
||||
).Returns(callInfo =>
|
||||
{
|
||||
var y = callInfo.ArgAt<int?>(0);
|
||||
var m = callInfo.ArgAt<int?>(1);
|
||||
@@ -106,7 +106,7 @@ public class TransactionStatisticsServiceTest : BaseTest
|
||||
// In GetTrendStatisticsAsync: transactionRepository.QueryAsync(year: targetYear, month: targetMonth...)
|
||||
// It does NOT pass type. So type is null.
|
||||
// But Service THEN filters by Type in memory.
|
||||
|
||||
|
||||
return query.ToList();
|
||||
});
|
||||
|
||||
@@ -178,7 +178,7 @@ public class TransactionStatisticsServiceTest : BaseTest
|
||||
// Assert
|
||||
result[("餐饮", TransactionType.Expense)].Should().Be(-150m); // Expect Negative (Sum of amounts)
|
||||
}
|
||||
|
||||
|
||||
// Additional tests from original file to maintain coverage, with minimal adjustments if needed
|
||||
[Fact]
|
||||
public async Task GetCategoryStatisticsAsync_支出分类()
|
||||
@@ -190,18 +190,18 @@ public class TransactionStatisticsServiceTest : BaseTest
|
||||
new() { Amount = -50m, Type = TransactionType.Expense, Classify = "餐饮" },
|
||||
new() { Amount = -200m, Type = TransactionType.Expense, Classify = "交通" }
|
||||
};
|
||||
|
||||
|
||||
// Mock filtering by Type
|
||||
_transactionRepository.QueryAsync(
|
||||
Arg.Any<int?>(), Arg.Any<int?>(), Arg.Any<DateTime?>(), Arg.Any<DateTime?>(), Arg.Any<TransactionType?>(), Arg.Any<string[]>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<int>(), Arg.Any<int>(), Arg.Any<bool>()
|
||||
).Returns(callInfo =>
|
||||
{
|
||||
var type = callInfo.ArgAt<TransactionType?>(4);
|
||||
return testData.Where(t => !type.HasValue || t.Type == type).ToList();
|
||||
});
|
||||
_transactionRepository.QueryAsync(
|
||||
Arg.Any<int?>(), Arg.Any<int?>(), Arg.Any<DateTime?>(), Arg.Any<DateTime?>(), Arg.Any<TransactionType?>(), Arg.Any<string[]>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<int>(), Arg.Any<int>(), Arg.Any<bool>()
|
||||
).Returns(callInfo =>
|
||||
{
|
||||
var type = callInfo.ArgAt<TransactionType?>(4);
|
||||
return testData.Where(t => !type.HasValue || t.Type == type).ToList();
|
||||
});
|
||||
|
||||
var result = await _service.GetCategoryStatisticsAsync(year, month, TransactionType.Expense);
|
||||
|
||||
|
||||
result.First(c => c.Classify == "餐饮").Amount.Should().Be(150m);
|
||||
result.First(c => c.Classify == "交通").Amount.Should().Be(200m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user