36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Shogi.AcceptanceTests.TestSetup;
|
|
using Shogi.Contracts.Api;
|
|
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Shogi.AcceptanceTests;
|
|
|
|
#pragma warning disable xUnit1033 // There is a bug which provides a false positive of xUnit1033.
|
|
public class AcceptanceTests : IClassFixture<GuestTestFixture>
|
|
#pragma warning restore xUnit1033
|
|
{
|
|
private readonly GuestTestFixture fixture;
|
|
private readonly ITestOutputHelper console;
|
|
|
|
public AcceptanceTests(GuestTestFixture fixture, ITestOutputHelper console)
|
|
{
|
|
this.fixture = fixture;
|
|
this.console = console;
|
|
}
|
|
|
|
private HttpClient Service => fixture.Service;
|
|
|
|
[Fact]
|
|
public async Task CreateAndReadSession()
|
|
{
|
|
var createResponse = await Service.PostAsJsonAsync(new Uri("Session", UriKind.Relative), new CreateSessionCommand { Name = "Acceptance Tests" });
|
|
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
|
|
var yep = await createResponse.Content.ReadAsStringAsync();
|
|
console.WriteLine(yep);
|
|
|
|
var readAllResponse = await Service.GetFromJsonAsync<ReadAllSessionsResponse>(new Uri("Session", UriKind.Relative));
|
|
readAllResponse.Should().NotBeNull();
|
|
readAllResponse!.AllOtherSessions.Should().ContainSingle(session => session.Name == "Acceptance Tests" && session.PlayerCount == 1);
|
|
}
|
|
} |