C# formatting
This commit is contained in:
@@ -14,7 +14,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task State_endpoint_returns_expected_payload_for_authenticated_user()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("payload");
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
@@ -27,7 +27,7 @@ public class StateTests
|
||||
|
||||
var state = await client.GetFromJsonAsync<JsonElement>("/api/state");
|
||||
|
||||
Assert.Equal(Phase.Suggest.ToString(), state.GetProperty("currentPhase").GetString());
|
||||
Assert.Equal(nameof(Phase.Suggest), state.GetProperty("currentPhase").GetString());
|
||||
Assert.False(state.GetProperty("votesFinal").GetBoolean());
|
||||
Assert.True(state.GetProperty("hasJoker").GetBoolean());
|
||||
Assert.True(state.GetProperty("players").GetInt32() >= 1);
|
||||
@@ -38,7 +38,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task GetPhase_upgrades_reveal_and_resets_when_results_close()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
Guid playerId = Guid.Empty;
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
{
|
||||
@@ -47,8 +47,8 @@ public class StateTests
|
||||
Id = Guid.NewGuid(),
|
||||
Username = "legacy",
|
||||
NormalizedUsername = "legacy",
|
||||
PasswordHash = new byte[] { 1 },
|
||||
PasswordSalt = new byte[] { 1 },
|
||||
PasswordHash = [1],
|
||||
PasswordSalt = [1],
|
||||
DisplayName = "Legacy",
|
||||
CurrentPhase = Phase.Reveal,
|
||||
VotesFinal = true
|
||||
@@ -63,7 +63,7 @@ public class StateTests
|
||||
using (var scope = factory.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var phase = await GameList.Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
var phase = await Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
Assert.Equal(Phase.Results, phase);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class StateTests
|
||||
using (var scope = factory.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var phase = await GameList.Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
var phase = await Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
var player = await db.Players.FindAsync(playerId);
|
||||
Assert.Equal(Phase.Vote, phase);
|
||||
Assert.False(player!.VotesFinal);
|
||||
@@ -87,7 +87,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task Phase_next_advances_and_clears_votesfinal()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("advance");
|
||||
|
||||
@@ -111,13 +111,13 @@ public class StateTests
|
||||
toResults.EnsureSuccessStatusCode();
|
||||
var me = await client.GetFromJsonAsync<JsonElement>("/api/me");
|
||||
Assert.False(me.GetProperty("votesFinal").GetBoolean());
|
||||
Assert.Equal(Phase.Results.ToString(), me.GetProperty("currentPhase").GetString());
|
||||
Assert.Equal(nameof(Phase.Results), me.GetProperty("currentPhase").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Phase_prev_moves_back_and_clears_votesfinal()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var admin = factory.CreateClientWithCookies();
|
||||
await admin.RegisterAsync("admin", admin: true);
|
||||
|
||||
@@ -132,14 +132,14 @@ public class StateTests
|
||||
backToSuggest.EnsureSuccessStatusCode();
|
||||
|
||||
var me = await admin.GetFromJsonAsync<JsonElement>("/api/me");
|
||||
Assert.Equal(Phase.Suggest.ToString(), me.GetProperty("currentPhase").GetString());
|
||||
Assert.Equal(nameof(Phase.Suggest), me.GetProperty("currentPhase").GetString());
|
||||
Assert.False(me.GetProperty("votesFinal").GetBoolean());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Name_endpoint_rejects_over_16_chars()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("namelimit");
|
||||
|
||||
@@ -150,7 +150,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task Cannot_advance_to_results_when_locked()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("player");
|
||||
|
||||
@@ -165,7 +165,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task Admin_opening_results_moves_players_to_results_phase()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var admin = factory.CreateClientWithCookies();
|
||||
await admin.RegisterAsync("admin", admin: true);
|
||||
|
||||
@@ -177,14 +177,14 @@ public class StateTests
|
||||
|
||||
var state = await player.GetFromJsonAsync<JsonElement>("/api/state");
|
||||
|
||||
Assert.Equal(Phase.Results.ToString(), state.GetProperty("currentPhase").GetString());
|
||||
Assert.Equal(nameof(Phase.Results), state.GetProperty("currentPhase").GetString());
|
||||
Assert.True(state.GetProperty("resultsOpen").GetBoolean());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Name_endpoint_trims_and_rejects_blank()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("nametest");
|
||||
|
||||
@@ -200,7 +200,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task Phase_prev_admin_only()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var player = factory.CreateClientWithCookies();
|
||||
await player.RegisterAsync("phase");
|
||||
|
||||
@@ -213,13 +213,13 @@ public class StateTests
|
||||
var back = await admin.PostAsJsonAsync("/api/me/phase/prev", new { });
|
||||
back.EnsureSuccessStatusCode();
|
||||
var me = await admin.GetFromJsonAsync<JsonElement>("/api/me");
|
||||
Assert.Equal(Phase.Suggest.ToString(), me.GetProperty("currentPhase").GetString());
|
||||
Assert.Equal(nameof(Phase.Suggest), me.GetProperty("currentPhase").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task State_endpoint_requires_auth_and_counts()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var anon = factory.CreateClient();
|
||||
var unauthorized = await anon.GetAsync("/api/state");
|
||||
Assert.NotEqual(HttpStatusCode.OK, unauthorized.StatusCode);
|
||||
@@ -237,7 +237,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task Health_endpoint_ok()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var resp = await factory.CreateClient().GetFromJsonAsync<JsonElement>("/health");
|
||||
Assert.Equal("ok", resp.GetProperty("status").GetString());
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class StateTests
|
||||
[Fact]
|
||||
public async Task GetPhase_aligns_to_results_when_open()
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory();
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
{
|
||||
var player = new Player
|
||||
@@ -253,8 +253,8 @@ public class StateTests
|
||||
Id = Guid.NewGuid(),
|
||||
Username = "phase",
|
||||
NormalizedUsername = "phase",
|
||||
PasswordHash = new byte[] { 1 },
|
||||
PasswordSalt = new byte[] { 1 },
|
||||
PasswordHash = [1],
|
||||
PasswordSalt = [1],
|
||||
DisplayName = "phase",
|
||||
CurrentPhase = Phase.Vote
|
||||
};
|
||||
@@ -267,7 +267,7 @@ public class StateTests
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var playerId = await db.Players.Select(p => p.Id).FirstAsync();
|
||||
var phase = await GameList.Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
var phase = await Endpoints.EndpointHelpers.GetPhase(db, playerId);
|
||||
|
||||
Assert.Equal(Phase.Results, phase);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user