Esempio n. 1
0
        private static void ValidateSetScoresValues(IList <Score> setScores, bool isTechnicalDefeat)
        {
            var isPreviousOptionalSetUnplayed = false;

            for (int i = 0, setOrderNumber = 1; i < setScores.Count; i++, setOrderNumber++)
            {
                if (i < GameResultConstants.SETS_COUNT_TO_WIN)
                {
                    if (!ResultValidation.IsRequiredSetScoreValid(setScores[i], isTechnicalDefeat))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      Resources.GameResultRequiredSetScores,
                                      GameResultConstants.SET_POINTS_MIN_VALUE_TO_WIN,
                                      GameResultConstants.SET_POINTS_MIN_DELTA_TO_WIN,
                                      GameResultConstants.TECHNICAL_DEFEAT_SET_WINNER_SCORE,
                                      GameResultConstants.TECHNICAL_DEFEAT_SET_LOSER_SCORE));
                    }
                }
                else
                {
                    ValidateSetScoresValuesHigherThanSetCountToWin(setScores, i, setOrderNumber,
                                                                   ref isPreviousOptionalSetUnplayed, isTechnicalDefeat);
                }
            }
        }
Esempio n. 2
0
        private void ValidateSetScoresValues(IList <Score> setScores, bool isTechnicalDefeat)
        {
            bool isPreviousOptionalSetUnplayed = false;

            for (int i = 0, setOrderNumber = 1; i < setScores.Count; i++, setOrderNumber++)
            {
                if (i < GameResultConstants.SETS_COUNT_TO_WIN)
                {
                    if (!ResultValidation.IsRequiredSetScoreValid(setScores[i], isTechnicalDefeat))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      Resources.GameResultRequiredSetScores,
                                      GameResultConstants.SET_POINTS_MIN_VALUE_TO_WIN,
                                      GameResultConstants.SET_POINTS_MIN_DELTA_TO_WIN,
                                      GameResultConstants.TECHNICAL_DEFEAT_SET_WINNER_SCORE,
                                      GameResultConstants.TECHNICAL_DEFEAT_SET_LOSER_SCORE));
                    }
                }
                else
                {
                    if (!ResultValidation.IsOptionalSetScoreValid(setScores[i], isTechnicalDefeat, setOrderNumber))
                    {
                        if (setOrderNumber == GameResultConstants.MAX_SETS_COUNT)
                        {
                            throw new ArgumentException(
                                      string.Format(
                                          Resources.GameResultFifthSetScoreInvalid,
                                          GameResultConstants.FIFTH_SET_POINTS_MIN_VALUE_TO_WIN,
                                          GameResultConstants.SET_POINTS_MIN_DELTA_TO_WIN));
                        }

                        throw new ArgumentException(
                                  string.Format(
                                      Resources.GameResultOptionalSetScores,
                                      GameResultConstants.SET_POINTS_MIN_VALUE_TO_WIN,
                                      GameResultConstants.SET_POINTS_MIN_DELTA_TO_WIN,
                                      GameResultConstants.UNPLAYED_SET_HOME_SCORE,
                                      GameResultConstants.UNPLAYED_SET_AWAY_SCORE));
                    }

                    if (isPreviousOptionalSetUnplayed)
                    {
                        if (!ResultValidation.IsSetUnplayed(setScores[i]))
                        {
                            throw new ArgumentException(Resources.GameResultPreviousOptionalSetUnplayed);
                        }
                    }

                    isPreviousOptionalSetUnplayed = ResultValidation.IsSetUnplayed(setScores[i]);
                }
            }
        }