コード例 #1
0
        public void PlayGame(Guid redOffensive,
                            Guid redDefensive,
                            Guid blueOffensive,
                            Guid blueDefensive,
                            int scoreRed,
                            int scoreBlue)
        {
            ValidatePlayers(redOffensive, redDefensive, blueOffensive, blueDefensive);
            var scoreValidator = new ScoreValidator(scoreRed, scoreBlue);
            if (!scoreValidator.IsValid)
            {
                throw new InvalidOperationException(scoreValidator.Message);
            }

            var @event = new GamePlayed
                             {
                                 RedOffensive = redOffensive,
                                 RedDefensive=redDefensive,
                                 BlueOffensive=blueOffensive,
                                 BlueDefensive = blueDefensive,
                                 ScoreRed = scoreRed,
                                 ScoreBlue = scoreBlue,
                             };
            Append(@event);
            Apply(@event);
        }
コード例 #2
0
        public void PlayGame(Guid redOffensive,
                             Guid redDefensive,
                             Guid blueOffensive,
                             Guid blueDefensive,
                             int scoreRed,
                             int scoreBlue)
        {
            ValidatePlayers(redOffensive, redDefensive, blueOffensive, blueDefensive);
            var scoreValidator = new ScoreValidator(scoreRed, scoreBlue);

            if (!scoreValidator.IsValid)
            {
                throw new InvalidOperationException(scoreValidator.Message);
            }

            var @event = new GamePlayed
            {
                RedOffensive  = redOffensive,
                RedDefensive  = redDefensive,
                BlueOffensive = blueOffensive,
                BlueDefensive = blueDefensive,
                ScoreRed      = scoreRed,
                ScoreBlue     = scoreBlue,
            };

            Append(@event);
            Apply(@event);
        }
コード例 #3
0
 public void ValidateScore(int scoreRed, int scoreBlue, bool expect)
 {
     var validator = new ScoreValidator(scoreRed, scoreBlue);
     Assert.AreEqual(expect, validator.IsValid, validator.Message);
 }