36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
|
|
using FluentAssertions;
|
|||
|
|
|
|||
|
|
namespace WebApi.Test.Repository;
|
|||
|
|
|
|||
|
|
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();
|
|||
|
|
archive!.Month.Should().Be(1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[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);
|
|||
|
|
}
|
|||
|
|
}
|