public void CreateNewGame_NewGameHasOnlyFirstSetRunning() { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var set = Assert.IsType <FirstSetRunning>(game.Sets); Assert.Equal(0, set.Set.BlueTeamScore); Assert.Equal(0, set.Set.RedTeamScore); }
public void TieAfterTwoSets_ThirdSetIsCreated() { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var newGame = Enumerable .Range(0, 20).Aggregate(game, (c, n) => c.AddPointForTeam(n < 10 ? Team.Blue : Team.Red)); Assert.IsType <ThirdSetRunning>(newGame.Sets); }
public void OneTeamWinsTwoSetsInRow_GameIsFinished(Team team) { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var newGame = Enumerable.Range(0, 20).Aggregate(game, (c, _) => c.AddPointForTeam(team)); var sets = Assert.IsType <FinishedSets>(newGame.Sets); Assert.Equal(team, sets.WinnerTeam); }
public void Add10PointsForTeam_SetIsFinished(Team team) { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var newGame = Enumerable.Range(0, 10).Aggregate(game, (c, _) => c.AddPointForTeam(team)); var(firstSet, _) = Assert.IsType <SecondSetRunning>(newGame.Sets); Assert.Equal(team == Team.Blue ? 10 : 0, firstSet.BlueTeamScore); Assert.Equal(team == Team.Blue ? 0 : 10, firstSet.RedTeamScore); }
public void AddPointForTeam_ScoreIsIncremented(Team team) { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var newGame = game.AddPointForTeam(team); var set = Assert.IsType <FirstSetRunning>(newGame.Sets); Assert.Equal(team == Team.Blue ? 1 : 0, set.Set.BlueTeamScore); Assert.Equal(team == Team.Blue ? 0 : 1, set.Set.RedTeamScore); }
public void OneTeamsWinsNotInRow_ThirdSetIsFinishedAndResultIsCounted(Team team) { var game = FoosballGame.Initialize(new CreateFoosballGame(Guid.NewGuid(), DateTime.Now)); var newGame = Enumerable .Range(0, 20).Aggregate(game, (c, n) => c.AddPointForTeam(n < 10 ? Team.Blue : Team.Red)); newGame = Enumerable.Range(0, 10).Aggregate(newGame, (c, _) => c.AddPointForTeam(team)); var sets = Assert.IsType <FinishedSets>(newGame.Sets); Assert.Equal(team, sets.WinnerTeam); }
public async Task HandleAsync(CreateFoosballGame command) { var game = FoosballGame.Initialize(command); await _foosballGamesRepository.Add(game); }