コード例 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TotalMatchesPlayed;
         hashCode = (hashCode * 397) ^ MaximumMatchesPerDay;
         hashCode = (hashCode * 397) ^ AverageMatchesPerDay.GetHashCode();
         hashCode = (hashCode * 397) ^ MaximumPopulation;
         hashCode = (hashCode * 397) ^ AveragePopulation.GetHashCode();
         hashCode = (hashCode * 397) ^ (Top5GameModes?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Top5Maps?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
コード例 #2
0
ファイル: PlayerStat.cs プロジェクト: ChizhovYuI/learn_1
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TotalMatchesPlayed;
         hashCode = (hashCode * 397) ^ TotalMatchesWon;
         hashCode = (hashCode * 397) ^ (FavoriteServer?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ UniqueServers;
         hashCode = (hashCode * 397) ^ (FavoriteGameMode?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ AverageScoreboardPercent.GetHashCode();
         hashCode = (hashCode * 397) ^ MaximumMatchesPerDay;
         hashCode = (hashCode * 397) ^ AverageMatchesPerDay.GetHashCode();
         hashCode = (hashCode * 397) ^ LastMatchPlayed.GetHashCode();
         hashCode = (hashCode * 397) ^ KillToDeathRatio.GetHashCode();
         return(hashCode);
     }
 }
コード例 #3
0
        public void CorrectlyCalculateAverageMatchesPerDay_WhenAdded()
        {
            var matchData = new MatchData("localhost-8081", _dateTime2,
                                          JsonConvert.DeserializeObject <MatchInfo>(_matchInfo2));
            var stat = new AverageMatchesPerDay();

            for (var i = 0; i < 7; i++)
            {
                for (var j = i; j < 7; j++)
                {
                    matchData.Timestamp = DateTime.Now.AddDays(i);
                    stat.Add(matchData, "player1");
                }
            }
            stat.Get(_dict);
            Assert.Less(Math.Abs((double)_dict["averageMatchesPerDay"] - (7 + 6 + 5 + 4 + 3 + 2 + 1) / 7.0), 10e-8);
        }