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:
@@ -51,7 +51,7 @@ public class TransactionPeriodicServiceTest : BaseTest
|
||||
// Assert
|
||||
// Service inserts Amount directly from periodicBill.Amount (100 is positive)
|
||||
await _transactionRepository.Received(1).AddAsync(Arg.Is<TransactionRecord>(t =>
|
||||
t.Amount == 100m &&
|
||||
t.Amount == 100m &&
|
||||
t.Type == TransactionType.Expense &&
|
||||
t.Classify == "餐饮" &&
|
||||
t.Reason == "每日餐费" &&
|
||||
@@ -69,7 +69,7 @@ public class TransactionPeriodicServiceTest : BaseTest
|
||||
|
||||
await _periodicRepository.Received(1).UpdateExecuteTimeAsync(
|
||||
Arg.Is(1L),
|
||||
Arg.Any<DateTime>(),
|
||||
Arg.Any<DateTime>(),
|
||||
Arg.Any<DateTime?>()
|
||||
);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class TransactionPeriodicServiceTest : BaseTest
|
||||
m.Content.Contains("每月工资")
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task ExecutePeriodicBillsAsync_未达到执行时间()
|
||||
{
|
||||
@@ -158,7 +158,7 @@ public class TransactionPeriodicServiceTest : BaseTest
|
||||
{
|
||||
Id = 1,
|
||||
PeriodicType = PeriodicType.Weekly,
|
||||
PeriodicConfig = "1,3,5",
|
||||
PeriodicConfig = "1,3,5",
|
||||
Amount = 200m,
|
||||
Type = TransactionType.Expense,
|
||||
Classify = "交通",
|
||||
@@ -191,7 +191,7 @@ public class TransactionPeriodicServiceTest : BaseTest
|
||||
Classify = "餐饮",
|
||||
Reason = "每日餐费",
|
||||
IsEnabled = true,
|
||||
LastExecuteTime = DateTime.Today,
|
||||
LastExecuteTime = DateTime.Today,
|
||||
NextExecuteTime = DateTime.Today.AddDays(1)
|
||||
};
|
||||
|
||||
|
||||
@@ -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