Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Fix for player fines
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsampica committed May 18, 2022
1 parent 8c2b7a2 commit e8dd0b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Server/Features/Dashboard/TopOffenders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public TopOffendersHandler(ApplicationDbContext dbContext, IMapper mapper)
public async Task<TopOffendersResult> Handle(TopOffendersQuery request, CancellationToken cancellationToken)
{
var players = await _dbContext.Players
.Where(p => p.Fines.Any(f => f.Status))
.OrderByDescending(p => p.Fines.Sum(f => f.Amount))
.Take(10)
.ProjectTo<TopOffendersResult.PlayerItem>(_mapper.ConfigurationProvider)
Expand Down
20 changes: 20 additions & 0 deletions src/Tests/Features/Dashboard/TopOffendersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ public async Task GivenUnauthenticatedUser_ThenDoesNotAllowAccess()
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
}

[Fact]
public async Task GivenAnyAuthenticatedUser_WhenThereIsOnePlayerWithoutAFine_ThenReturnsZeroPlayers()
{
var application = CreateUserAuthenticatedApplication();

var stubTeam = CreateFakeTeam();
await application.AddAsync(stubTeam);

var mockPlayer = CreateFakePlayer();
mockPlayer.TeamId = stubTeam.Id;
await application.AddAsync(mockPlayer);

var client = application.CreateClient();

var result = await client.GetFromJsonAsync<TopOffendersResult>(TopOffendersRouteFactory.Uri);

result.Should().NotBeNull();
result!.Players.Should().HaveCount(0);
}

[Fact]
public async Task GivenAnyAuthenticatedUser_WhenThereIsOnePlayerWithAFine_ThenReturnsOnePlayerWithAFine()
{
Expand Down

0 comments on commit e8dd0b1

Please sign in to comment.