Add tests
This commit is contained in:
1 parent
d5127c7405
commit
88aaaecb1a
15 files changed
+1755
-34
No files matched your search
@@ -3,14 +3,9 @@ using BudgetApp.Data;
|
||||
|
||||
namespace BudgetApp.Services;
|
||||
|
||||
public class AccountService
|
||||
public class AccountService(ApplicationDbContext db)
|
||||
{
|
||||
private readonly ApplicationDbContext _db;
|
||||
|
||||
public AccountService(ApplicationDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
private readonly ApplicationDbContext _db = db;
|
||||
|
||||
public async Task<List<Account>> GetAccountsAsync(string userId)
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ using BudgetApp.Data;
|
||||
|
||||
namespace BudgetApp.Services;
|
||||
|
||||
public class CategoryService
|
||||
public class CategoryService(ApplicationDbContext db)
|
||||
{
|
||||
private readonly ApplicationDbContext _db;
|
||||
private readonly ApplicationDbContext _db = db;
|
||||
|
||||
private static readonly (string Name, string Icon)[] DefaultCategories =
|
||||
[
|
||||
@@ -26,11 +26,6 @@ public class CategoryService
|
||||
("Gifts", "🎁")
|
||||
];
|
||||
|
||||
public CategoryService(ApplicationDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public async Task<List<Category>> GetCategoriesAsync(string userId)
|
||||
{
|
||||
return await _db.Categories
|
||||
|
||||
@@ -2,18 +2,11 @@ using BudgetApp.Data;
|
||||
|
||||
namespace BudgetApp.Services;
|
||||
|
||||
public class DashboardService
|
||||
public class DashboardService(TransactionService transactionService, AccountService accountService, CategoryService categoryService)
|
||||
{
|
||||
private readonly TransactionService _transactionService;
|
||||
private readonly AccountService _accountService;
|
||||
private readonly CategoryService _categoryService;
|
||||
|
||||
public DashboardService(TransactionService transactionService, AccountService accountService, CategoryService categoryService)
|
||||
{
|
||||
_transactionService = transactionService;
|
||||
_accountService = accountService;
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
private readonly TransactionService _transactionService = transactionService;
|
||||
private readonly AccountService _accountService = accountService;
|
||||
private readonly CategoryService _categoryService = categoryService;
|
||||
|
||||
public async Task<DashboardData> GetDashboardDataAsync(string userId, DateTime? from = null, DateTime? to = null)
|
||||
{
|
||||
@@ -53,7 +46,7 @@ public class DashboardService
|
||||
};
|
||||
}
|
||||
|
||||
private static ChartData BuildChartData(List<Account> accounts, List<Transaction> transactions, DateTime startDate, DateTime endDate)
|
||||
internal static ChartData BuildChartData(List<Account> accounts, List<Transaction> transactions, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
var labels = new List<string>();
|
||||
|
||||
@@ -3,14 +3,9 @@ using BudgetApp.Data;
|
||||
|
||||
namespace BudgetApp.Services;
|
||||
|
||||
public class TransactionService
|
||||
public class TransactionService(ApplicationDbContext db)
|
||||
{
|
||||
private readonly ApplicationDbContext _db;
|
||||
|
||||
public TransactionService(ApplicationDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
private readonly ApplicationDbContext _db = db;
|
||||
|
||||
public async Task<List<Transaction>> GetTransactionsAsync(string userId)
|
||||
{
|
||||
@@ -248,7 +243,7 @@ public class TransactionService
|
||||
}
|
||||
}
|
||||
|
||||
private static DateTime GetNextOccurrence(DateTime current, RecurrenceType recurrence) => recurrence switch
|
||||
internal static DateTime GetNextOccurrence(DateTime current, RecurrenceType recurrence) => recurrence switch
|
||||
{
|
||||
RecurrenceType.Daily => current.AddDays(1),
|
||||
RecurrenceType.Weekly => current.AddDays(7),
|
||||
|
||||
Reference in new issue
Block a user