Пример #1
0
        public void EocStatsData_GetNextUpdateTime_ReturnsGivenUtcNowValueWhenLastUpdatedValueIsInTheFuture()
        {
            DateTime utcNow = DateTime.UtcNow;

            Assert.AreEqual(utcNow,
                            EocStatsData.GetNextUpdateTime(DateTime.MaxValue, utcNow, false));
        }
Пример #2
0
        /// <summary>
        /// Updates the data container
        /// </summary>
        /// <param name="eocNode">EOC Stats XmlNode</param>
        private static EocStatsData CreateStatsDataFromXmlNode(XmlNode eocNode)
        {
            XmlNode teamNode = eocNode.SelectSingleNode("team");
            XmlNode userNode = eocNode.SelectSingleNode("user");

            var data = new EocStatsData(DateTime.UtcNow);

            data.UserTwentyFourHourAverage = Convert.ToInt64(GetXmlNode(userNode, "Points_24hr_Avg").InnerText);
            data.UserPointsToday           = Convert.ToInt64(GetXmlNode(userNode, "Points_Today").InnerText);
            data.UserPointsWeek            = Convert.ToInt64(GetXmlNode(userNode, "Points_Week").InnerText);
            data.UserPointsTotal           = Convert.ToInt64(GetXmlNode(userNode, "Points").InnerText);
            data.UserWorkUnitsTotal        = Convert.ToInt64(GetXmlNode(userNode, "WUs").InnerText);
            data.UserPointsUpdate          = Convert.ToInt64(GetXmlNode(userNode, "Points_Update").InnerText);
            data.UserTeamRank    = Convert.ToInt32(GetXmlNode(userNode, "Team_Rank").InnerText);
            data.UserOverallRank = Convert.ToInt32(GetXmlNode(userNode, "Overall_Rank").InnerText);
            data.UserChangeRankTwentyFourHours = Convert.ToInt32(GetXmlNode(userNode, "Change_Rank_24hr").InnerText);
            data.UserChangeRankSevenDays       = Convert.ToInt32(GetXmlNode(userNode, "Change_Rank_7days").InnerText);
            data.TeamTwentyFourHourAverage     = Convert.ToInt64(GetXmlNode(teamNode, "Points_24hr_Avg").InnerText);
            data.TeamPointsToday               = Convert.ToInt64(GetXmlNode(teamNode, "Points_Today").InnerText);
            data.TeamPointsWeek                = Convert.ToInt64(GetXmlNode(teamNode, "Points_Week").InnerText);
            data.TeamPointsTotal               = Convert.ToInt64(GetXmlNode(teamNode, "Points").InnerText);
            data.TeamWorkUnitsTotal            = Convert.ToInt64(GetXmlNode(teamNode, "WUs").InnerText);
            data.TeamPointsUpdate              = Convert.ToInt64(GetXmlNode(teamNode, "Points_Update").InnerText);
            data.TeamRank                      = Convert.ToInt32(GetXmlNode(teamNode, "Rank").InnerText);
            data.TeamChangeRankTwentyFourHours = Convert.ToInt32(GetXmlNode(teamNode, "Change_Rank_24hr").InnerText);
            data.TeamChangeRankSevenDays       = Convert.ToInt32(GetXmlNode(teamNode, "Change_Rank_7days").InnerText);

            XmlNode statusNode = GetXmlNode(eocNode, "status");

            data.Status = GetXmlNode(statusNode, "Update_Status").InnerText;

            return(data);
        }
Пример #3
0
        public void EocStatsData_GetNextUpdateTime_WhenDuringDaylightSavingsTime()
        {
            DateTime utcNow = DateTime.UtcNow;
            // this value has to be in past, a future date will generate a result that equals DateTime.MinValue.
            DateTime lastUpdated = utcNow.Date.Subtract(TimeSpan.FromDays(1));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(2)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(0)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(2)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(1)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(5)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(2)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(5)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(3)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(5)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(4)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(8)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(5)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(8)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(6)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(8)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(7)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(11)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(8)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(11)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(9)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(11)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(10)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(14)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(11)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(14)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(12)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(14)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(13)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(17)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(14)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(17)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(15)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(17)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(16)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(20)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(17)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(20)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(18)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(20)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(19)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(23)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(20)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(23)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(21)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(TimeSpan.FromHours(23)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(22)), utcNow, true));

            Assert.AreEqual(lastUpdated.Add(new TimeSpan(1, 2, 0, 0)),
                            EocStatsData.GetNextUpdateTime(lastUpdated.Add(TimeSpan.FromHours(23)), utcNow, true));
        }