Exemple #1
0
        /// <summary>
        /// Finds out whether two <see cref="Game"/> objects are equal.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>True if given <see cref="Game"/> objects are equal.</returns>
        internal bool AreEqual(Game x, Game y)
        {
            var result = x.Id == y.Id &&
                         x.TournamentId == y.TournamentId &&
                         x.HomeTeamId == y.HomeTeamId &&
                         x.AwayTeamId == y.AwayTeamId &&
                         x.GameDate == y.GameDate &&
                         x.Round == y.Round &&
                         x.GameNumber == y.GameNumber;

            if (!result)
            {
                return(false);
            }

            if (x.Result == null && y.Result == null)
            {
                return(true);
            }

            if (x.Result != null && y.Result != null)
            {
                result = new ScoreComparer().Equals(x.Result.GameScore, y.Result.GameScore) &&
                         x.Result.GameScore.IsTechnicalDefeat == y.Result.GameScore.IsTechnicalDefeat &&
                         x.Result.SetScores.SequenceEqual(y.Result.SetScores, new ScoreComparer()) &&
                         PenaltiesAreEqual(x.Result.Penalty, y.Result.Penalty);
            }
            else
            {
                result = false;
            }

            return(result);
        }
        /// <summary>
        /// Finds out whether two <see cref="GameResultDto"/> objects are equal.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>True if given <see cref="GameResultDto"/> objects are equal.</returns>
        internal bool AreEqual(GameResultDto x, GameResultDto y)
        {
            var scoreComparer = new ScoreComparer();

            return(x.Id == y.Id &&
                   x.TournamentId == y.TournamentId &&
                   x.HomeTeamId == y.HomeTeamId &&
                   x.AwayTeamId == y.AwayTeamId &&
                   x.HomeTeamName == y.HomeTeamName &&
                   x.AwayTeamName == y.AwayTeamName &&
                   scoreComparer.Equals(x.Result.GameScore, y.Result.GameScore) &&
                   scoreComparer.Equals(x.Result.SetScores[0], y.Result.SetScores[0]) &&
                   scoreComparer.Equals(x.Result.SetScores[1], y.Result.SetScores[1]) &&
                   scoreComparer.Equals(x.Result.SetScores[2], y.Result.SetScores[2]) &&
                   scoreComparer.Equals(x.Result.SetScores[3], y.Result.SetScores[3]) &&
                   scoreComparer.Equals(x.Result.SetScores[4], y.Result.SetScores[4]) &&
                   x.GameDate == y.GameDate &&
                   x.Round == y.Round &&
                   x.GameNumber == y.GameNumber);
        }