2026-01-28 19:32:11 +08:00
|
|
|
|
namespace WebApi.Test.Repository;
|
2026-01-28 17:00:58 +08:00
|
|
|
|
|
|
|
|
|
|
public class BudgetArchiveRepositoryTest : RepositoryTestBase
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IBudgetArchiveRepository _repository;
|
|
|
|
|
|
|
|
|
|
|
|
public BudgetArchiveRepositoryTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
_repository = new BudgetArchiveRepository(FreeSql);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public async Task GetArchiveAsync_获取单条归档_Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.AddAsync(new BudgetArchive { Year = 2023, Month = 1 });
|
|
|
|
|
|
await _repository.AddAsync(new BudgetArchive { Year = 2023, Month = 2 });
|
|
|
|
|
|
|
|
|
|
|
|
var archive = await _repository.GetArchiveAsync(2023, 1);
|
|
|
|
|
|
archive.Should().NotBeNull();
|
2026-01-28 19:32:11 +08:00
|
|
|
|
archive.Month.Should().Be(1);
|
2026-01-28 17:00:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public async Task GetArchivesByYearAsync_按年获取_Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.AddAsync(new BudgetArchive { Year = 2023, Month = 1 });
|
|
|
|
|
|
await _repository.AddAsync(new BudgetArchive { Year = 2023, Month = 2 });
|
|
|
|
|
|
await _repository.AddAsync(new BudgetArchive { Year = 2022, Month = 12 });
|
|
|
|
|
|
|
|
|
|
|
|
var list = await _repository.GetArchivesByYearAsync(2023);
|
|
|
|
|
|
list.Should().HaveCount(2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|