-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unnecessary exception nonsense * Add fields to challenges report * Partially address #254 - allow alt names on certificates * MInor bug fixes * Fix name settings bug * Cleanup * Fix team session start bug * Unit test for ToLookup and snippet update * Tests * Add initial tests
- Loading branch information
1 parent
8211bb5
commit f7c9244
Showing
6 changed files
with
122 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/Gameboard.Api.Tests.Integration/Tests/Features/Teams/StartTeamSessionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Gameboard.Api.Common; | ||
using Gameboard.Api.Structure; | ||
|
||
namespace Gameboard.Api.Tests.Integration.Teams; | ||
|
||
public class TeamControllerStartTeamSessionTests(GameboardTestContext testContext) : IClassFixture<GameboardTestContext> | ||
{ | ||
private readonly GameboardTestContext _testContext = testContext; | ||
|
||
[Theory, GbIntegrationAutoData] | ||
public async Task TeamGame_WithSinglePlayer_CantStart | ||
( | ||
string gameId, | ||
string playerId, | ||
string userId, | ||
IFixture fixture | ||
) | ||
{ | ||
// given a team game and a registered player with no teammates | ||
await _testContext.WithDataState(state => | ||
{ | ||
state.Add(new Data.Game | ||
{ | ||
Id = gameId, | ||
MinTeamSize = 2, | ||
MaxTeamSize = 5, | ||
GameStart = DateTimeOffset.UtcNow, | ||
GameEnd = DateTimeOffset.UtcNow.AddDays(1), | ||
Mode = GameEngineMode.Standard, | ||
Players = state.Build<Data.Player>(fixture, p => | ||
{ | ||
p.Id = playerId; | ||
p.User = state.Build<Data.User>(fixture, u => u.Id = userId); | ||
}).ToCollection() | ||
}); | ||
}); | ||
|
||
// when they try to start their session | ||
await _testContext | ||
.CreateHttpClientWithActingUser(u => u.Id = userId) | ||
.PutAsync($"api/player/{playerId}/start", null) | ||
// they should get a validation error | ||
.ShouldYieldGameboardValidationException<GameboardAggregatedValidationExceptions>(); | ||
} | ||
|
||
[Theory, GbIntegrationAutoData] | ||
public async Task TeamGame_WithTwoPlayers_CanStart | ||
( | ||
string gameId, | ||
string playerId, | ||
string userId, | ||
string teamId, | ||
IFixture fixture | ||
) | ||
{ | ||
// given a team game and a registered player with no teammates | ||
await _testContext.WithDataState(state => | ||
{ | ||
state.Add(new Data.Game | ||
{ | ||
Id = gameId, | ||
MinTeamSize = 2, | ||
MaxTeamSize = 5, | ||
GameStart = DateTimeOffset.UtcNow, | ||
GameEnd = DateTimeOffset.UtcNow.AddDays(1), | ||
Mode = GameEngineMode.Standard, | ||
Players = | ||
[ | ||
state.Build<Data.Player>(fixture, p => | ||
{ | ||
p.Id = playerId; | ||
p.Role = PlayerRole.Manager; | ||
p.TeamId = teamId; | ||
p.User = state.Build<Data.User>(fixture, u => u.Id = userId); | ||
}), | ||
state.Build<Data.Player>(fixture, p => | ||
{ | ||
p.Id = fixture.Create<string>(); | ||
p.Role = PlayerRole.Member; | ||
p.TeamId = teamId; | ||
}) | ||
] | ||
}); | ||
}); | ||
|
||
// when they try to start their session | ||
var result = await _testContext | ||
.CreateHttpClientWithActingUser(u => u.Id = userId) | ||
.PutAsync($"api/player/{playerId}/start", null) | ||
.DeserializeResponseAs<Player>(); | ||
|
||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters