Skip to content

Commit

Permalink
#896: Introduce constants to reduce test verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
laingsimon committed Jun 26, 2024
1 parent c86d97b commit 781b3a8
Showing 1 changed file with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class DivisionDataDtoFactoryTests
Id = Guid.NewGuid(),
Name = "Away player",
};
private static readonly TeamDto otherDivisionTeam = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();

private readonly CancellationToken _token = new();
private DivisionDataDtoFactory _factory = null!;
Expand Down Expand Up @@ -170,10 +174,6 @@ public async Task CreateDivisionDataDto_GivenCrossDivisionalFixtures_SetsTeamsCo
.WithName("Team 1 - Playing")
.WithSeason(b => b.ForSeason(Season1, Division1).WithPlayers(Player1))
.Build();
var otherDivisionTeam = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(b => b.ForSeason(Season1).WithPlayers(Player2))
.Build();
var game = new GameBuilder()
.ForSeason(Season1)
.Knockout()
Expand Down Expand Up @@ -473,10 +473,6 @@ public async Task CreateDivisionDataDto_GivenCrossDivisionalFixtures_SetsCurrent
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1, Division1).WithPlayers(Player1))
.Build();
var otherDivisionTeam = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var game = new GameBuilder()
.ForSeason(Season1)
.ForDivision(Division1)
Expand Down Expand Up @@ -514,10 +510,6 @@ public async Task CreateDivisionDataDto_GivenTeamWithDeletedSeason_DoesNotInclud
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1, Division1).WithPlayers(Player1).Deleted())
.Build();
var otherDivisionTeam = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var game = new GameBuilder()
.ForSeason(Season1)
.ForDivision(Division1)
Expand Down Expand Up @@ -555,10 +547,6 @@ public async Task CreateDivisionDataDto_GivenCrossDivisionalAccolades_DoesNotRet
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1, Division1).WithPlayers(Player1))
.Build();
var otherDivisionTeam = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var game = new GameBuilder(new CosmosGame { AccoladesCount = true })
.ForSeason(Season1)
.Knockout()
Expand Down Expand Up @@ -592,12 +580,8 @@ public async Task CreateDivisionDataDto_GivenNoFixtures_ReturnsNoPlayers()
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player1))
.Build();
var team2 = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var context = new DivisionDataContextBuilder()
.WithTeam(team1, team2)
.WithTeam(team1, otherDivisionTeam)
.WithSeason(Season1)
.Build();

Expand All @@ -613,12 +597,8 @@ public async Task CreateDivisionDataDto_GivenNoFixturesWhenAPlayerManager_Return
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player1))
.Build();
var team2 = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var context = new DivisionDataContextBuilder()
.WithTeam(team1, team2)
.WithTeam(team1, otherDivisionTeam)
.WithSeason(Season1)
.Build();
_user = new UserDto
Expand All @@ -644,18 +624,14 @@ public async Task CreateDivisionDataDto_GivenFixturesWhenAPlayerManager_ReturnsA
.WithName("Team 1 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player1, new GamePlayer { Id = Guid.NewGuid(), Name = "Team 1 not playing player" }))
.Build();
var team2 = new TeamDtoBuilder()
.WithName("Team 2 - Playing")
.WithSeason(s => s.ForSeason(Season1).WithPlayers(Player2))
.Build();
var game = new GameBuilder()
.ForSeason(Season1)
.WithTeams(team1, team2)
.WithTeams(team1, otherDivisionTeam)
.WithMatch(m => m.WithScores(2, 3).WithHomePlayers(Player1).WithAwayPlayers(Player2))
.Build();
var context = new DivisionDataContextBuilder()
.WithGame(game)
.WithTeam(team1, team2)
.WithTeam(team1, otherDivisionTeam)
.WithSeason(Season1)
.Build();
_user = new UserDto
Expand Down

0 comments on commit 781b3a8

Please sign in to comment.