create, read, playercount

This commit is contained in:
2022-11-09 16:08:04 -06:00
parent a1f996e508
commit da76917490
37 changed files with 999 additions and 814 deletions

View File

@@ -1,62 +1,60 @@
using Microsoft.Extensions.Configuration;
namespace Shogi.AcceptanceTests.TestSetup
namespace Shogi.AcceptanceTests.TestSetup;
/// <summary>
/// Acceptance Test fixture for tests which assert features for Microsoft accounts.
/// </summary>
public class GuestTestFixture : IAsyncLifetime, IDisposable
{
/// <summary>
/// Acceptance Test fixture for tests which assert features for Microsoft accounts.
/// </summary>
public class GuestTestFixture : IAsyncLifetime, IDisposable
private bool disposedValue;
public GuestTestFixture()
{
private bool disposedValue;
Configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
public GuestTestFixture()
Service = new HttpClient
{
Configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
//.AddEnvironmentVariables()
.Build();
BaseAddress = new Uri(Configuration["ServiceUrl"], UriKind.Absolute)
};
}
Service = new HttpClient
public IConfiguration Configuration { get; private set; }
public HttpClient Service { get; }
public async Task InitializeAsync()
{
// Log in as a guest account and retain the session cookie for future requests.
var loginResponse = await Service.GetAsync(new Uri("User/LoginAsGuest", UriKind.Relative));
loginResponse.IsSuccessStatusCode.Should().BeTrue(because: "Guest accounts should work");
var guestSessionCookie = loginResponse.Headers.GetValues("Set-Cookie").SingleOrDefault();
Service.DefaultRequestHeaders.Add("Set-Cookie", guestSessionCookie);
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
BaseAddress = new Uri(Configuration["ServiceUrl"], UriKind.Absolute)
};
}
public IConfiguration Configuration { get; private set; }
public HttpClient Service { get; }
public async Task InitializeAsync()
{
// Log in as a guest account.
var loginResponse = await Service.GetAsync(new Uri("User/LoginAsGuest", UriKind.Relative));
loginResponse.EnsureSuccessStatusCode();
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
Service.Dispose();
}
disposedValue = true;
Service.Dispose();
}
}
public Task DisposeAsync()
{
Dispose(true);
return Task.CompletedTask;
}
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
disposedValue = true;
}
}
public Task DisposeAsync()
{
Dispose(true);
return Task.CompletedTask;
}
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}