public void Handle(Serie4Registered e, string aggregateId)
    {
        string id = ResultSeries4ReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeries4ReadModel results = DocumentSession.Load <ResultSeries4ReadModel>(id);

        MatchSerie4 matchSerie = e.MatchSerie;

        string[] playerIds = new[]
        {
            matchSerie.Game1.Player,
            matchSerie.Game2.Player,
            matchSerie.Game3.Player,
            matchSerie.Game4.Player
        };

        Dictionary <string, Player> players = DocumentSession.Load <Player>(playerIds).ToDictionary(x => x.Id);

        ResultSeries4ReadModel.Game game1 = CreateGame(players, matchSerie.Game1);
        ResultSeries4ReadModel.Game game2 = CreateGame(players, matchSerie.Game2);
        ResultSeries4ReadModel.Game game3 = CreateGame(players, matchSerie.Game3);
        ResultSeries4ReadModel.Game game4 = CreateGame(players, matchSerie.Game4);

        results.Series.Add(new ResultSeries4ReadModel.Serie
        {
            Games = new List <ResultSeries4ReadModel.Game>
            {
                game1,
                game2,
                game3,
                game4
            }
        });
    }
示例#2
0
    public MatchSerie4[] CreateMatchSeries()
    {
        List <MatchSerie4> matchSeries = new();

        ResultSeries4ReadModel.Serie[] series = new[]
        {
            Series.ElementAtOrDefault(0),
            Series.ElementAtOrDefault(1),
            Series.ElementAtOrDefault(2),
            Series.ElementAtOrDefault(3)
        };
        int serieNumber = 1;

        foreach (ResultSeries4ReadModel.Serie serie in series.Where(x => x != null))
        {
            List <MatchGame4> games = new();
            for (int i = 0; i < 4; i++)
            {
                ResultSeries4ReadModel.Game game = serie.Games[i];
                MatchGame4 matchGame             = new(game.Player, game.Score, game.Pins);
                games.Add(matchGame);
            }

            matchSeries.Add(new MatchSerie4(serieNumber++, games));
        }

        return(matchSeries.ToArray());
    }
 private static void VerifyGame(ResultSeries4ReadModel.Game game, Tuple <int, string, int> expected)
 {
     Assert.That(expected.Item1, Is.EqualTo(game.Score));
     Assert.That(expected.Item2, Is.EqualTo(game.Player));
     Assert.That(expected.Item3, Is.EqualTo(game.Pins));
 }