Exemplo n.º 1
0
        public void FinishMatchHappyPath()
        {
            var match = new Matchup();

            var player1Id      = Guid.NewGuid();
            var player2Id      = Guid.NewGuid();
            var player3Id      = Guid.NewGuid();
            var player4Id      = Guid.NewGuid();
            var player5Id      = Guid.NewGuid();
            var teamReadModel  = TeamReadModel(player1Id, player2Id);
            var teamReadModel2 = TeamReadModel(player3Id, player4Id, player5Id);

            var matchId = Guid.NewGuid();

            match.Apply(new MatchCreated(matchId, teamReadModel.TeamId, teamReadModel2.TeamId));
            match.Apply(new MatchStarted(matchId, teamReadModel.Players, teamReadModel2.Players));

            var playerProgression1 = PlayerProgressionTouchdown(player2Id);
            var playerProgression2 = PlayerProgressionNormal(player4Id);

            var prog1 = match.ProgressMatch(playerProgression1);
            var prog2 = match.ProgressMatch(playerProgression2);

            match.Apply(prog1.DomainEvents);
            match.Apply(prog2.DomainEvents);

            var domainResult = match.Finish();

            var domainEvent = domainResult.DomainEvents.First() as MatchFinished;

            Assert.AreEqual(teamReadModel.TeamId, domainEvent.GameResult.Winner);
            Assert.AreEqual(teamReadModel2.TeamId, domainEvent.GameResult.Looser);

            Assert.AreEqual(1, domainEvent.GameResult.HomeTeam.TouchDowns);
            Assert.AreEqual(0, domainEvent.GameResult.GuestTeam.TouchDowns);
        }