Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    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);
    }
Exemplo n.º 6
0
    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);
    }
Exemplo n.º 7
0
 public async Task HandleAsync(CreateFoosballGame command)
 {
     var game = FoosballGame.Initialize(command);
     await _foosballGamesRepository.Add(game);
 }