Files

42 lines
1.5 KiB
C#

using System.Net;
using System.Net.Http.Json;
namespace HSchool.AppHost.Tests;
[Collection(AppHostCollection.Name)]
public class LessonMarkApiTests(AppHostFixture fixture)
{
private static readonly DateTime Start = new(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc);
[Fact]
public async Task PostMark_IsNotAccepted()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
var school = await SchoolApiTests.CreateAsync(client, "Оценка API", Start, seed: 73);
var page = await client.GetFromJsonAsync<PeoplePage>(
$"/api/schools/{school.Id}/people?role=student&pageSize=1",
TestContext.Current.CancellationToken);
Assert.NotNull(page);
Assert.NotEmpty(page.People);
var personId = page.People[0].Id;
using var response = await client.PostAsJsonAsync(
$"/api/schools/{school.Id}/people/{personId}/marks",
new { subject = "Mathematics", value = 5, period = 1 },
TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
using var put = await client.PutAsJsonAsync(
$"/api/schools/{school.Id}/people/{personId}/marks",
new { subject = "Mathematics", value = 5, period = 1 },
TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.NotFound, put.StatusCode);
}
private sealed record PeoplePage(IReadOnlyList<PersonRow> People);
private sealed record PersonRow(string Id);
}