Skip to content

Commit

Permalink
#896: Introduce TournamentGameBuilder and Player constants to reduce …
Browse files Browse the repository at this point in the history
…duplication
  • Loading branch information
laingsimon committed Jun 14, 2024
1 parent 906d034 commit f704285
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 137 deletions.
49 changes: 49 additions & 0 deletions CourageScores.Tests/Models/Cosmos/Game/TournamentGameBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using CourageScores.Models.Cosmos.Game;
using CourageScores.Models.Dtos.Season;

namespace CourageScores.Tests.Models.Cosmos.Game;

public class TournamentGameBuilder
{
private readonly TournamentGame _tournament;

public TournamentGameBuilder(TournamentGame? tournament = null)
{
_tournament = tournament ?? new TournamentGame { Id = Guid.NewGuid() };
}

public TournamentGame Build()
{
return _tournament;
}

public TournamentGameBuilder WithDate(DateTime date)
{
_tournament.Date = date;
return this;
}

public TournamentGameBuilder WithSeason(SeasonDto season)
{
_tournament.SeasonId = season.Id;
return this;
}

public TournamentGameBuilder WithType(string type)
{
_tournament.Type = type;
return this;
}

public TournamentGameBuilder AccoladesCount(bool count = true)
{
_tournament.AccoladesCount = count;
return this;
}

public TournamentGameBuilder WithOneEighties(params TournamentPlayer[] players)
{
_tournament.OneEighties.AddRange(players);
return this;
}
}
Loading

0 comments on commit f704285

Please sign in to comment.