增强筛选
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Jiaowu.Api.Controllers;
|
||||
using Jiaowu.Api.Contracts;
|
||||
using Jiaowu.Api.Domain.Academic;
|
||||
using Jiaowu.Api.Domain.Identity;
|
||||
using Jiaowu.Api.Infrastructure.Auth;
|
||||
@@ -11,6 +12,37 @@ namespace Jiaowu.Api.Tests;
|
||||
|
||||
public sealed class OtherExamsControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Batches_AreFilteredAndReturnedByPage()
|
||||
{
|
||||
await using var connection = new SqliteConnection("Data Source=:memory:");
|
||||
await connection.OpenAsync();
|
||||
await using var db = new AppDbContext(
|
||||
new DbContextOptionsBuilder<AppDbContext>().UseSqlite(connection).Options);
|
||||
await db.Database.EnsureCreatedAsync();
|
||||
db.OtherExamBatches.AddRange(Enumerable.Range(1, 11).Select(number =>
|
||||
new OtherExamBatch
|
||||
{
|
||||
ExamCode = $"CET-{number:00}",
|
||||
Name = $"英语等级考试 {number}",
|
||||
ExamDate = new DateOnly(2026, 6, number),
|
||||
MetricKind = OtherExamMetricKind.Score,
|
||||
MaxScore = 100,
|
||||
Status = number == 11
|
||||
? OtherExamBatchStatus.Published
|
||||
: OtherExamBatchStatus.Draft
|
||||
}));
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var controller = new OtherExamsController(db, new TestDataScope(Guid.NewGuid()));
|
||||
var result = Assert.IsType<OkObjectResult>(await controller.GetBatches(
|
||||
keyword: "英语", status: OtherExamBatchStatus.Draft, page: 1,
|
||||
pageSize: 10, ct: CancellationToken.None));
|
||||
var page = Assert.IsType<PagedResult<object>>(result.Value);
|
||||
Assert.Equal(10, page.Total);
|
||||
Assert.Equal(10, page.Items.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReplaceResults_ReplacesExistingResultsInsideTransaction()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user