Exemplo n.º 1
0
 public static void saveBoxScore(BoxScore boxScore)
 {
     var fileName = buildFilePath(boxScore.Year, boxScore.Week, boxScore.TeamId, _typeBs);
     var serializer = new XmlSerializer(typeof(BoxScore));
     var writer = new StreamWriter(fileName);
     serializer.Serialize(writer, boxScore);
     writer.Close();
 }
Exemplo n.º 2
0
        public void ECWeeks1And2BoxScore()
        {
            var map = new FantasyFootballMap();

            // week 1
            map.NavigateToUrl(getBoxScore(erikId, 1));
            var boxScore = new BoxScore(map.getHtml(), erikId, 1, year);
            Assert.AreEqual(5, boxScore.TotalSacks);
            Assert.AreEqual(56, boxScore.LongPunt);
            Assert.AreEqual("Dan Bailey", boxScore.LongestFieldGoalKicker);
            Assert.AreEqual(32, boxScore.LongestFieldGoal);
            Assert.AreEqual(14.3, boxScore.HomeQBPts);
            Assert.AreEqual(12.4, boxScore.HomeRB1Pts);
            Assert.AreEqual(13.1, boxScore.HomeRB2Pts);
            Assert.AreEqual(4.8,  boxScore.HomeWR1Pts);
            Assert.AreEqual(13.2, boxScore.HomeWR2Pts);
            Assert.AreEqual(12.3, boxScore.HomeTEPts);
            Assert.AreEqual(10.7, boxScore.HomeFLEXPts);
            Assert.AreEqual(27,   boxScore.HomeDefensePts);
            Assert.AreEqual(9,    boxScore.HomeKPts);
            Assert.AreEqual(27,   boxScore.MaxPlayerPoints);
            Assert.AreEqual("Panthers D/ST", boxScore.MaxPlayerPointsPlayer);
            Assert.AreEqual("Panthers D/ST", boxScore.HomeDefense);

            Assert.AreEqual(25,   boxScore.AwayQBPts);
            Assert.AreEqual(18.3, boxScore.AwayRB1Pts);
            Assert.AreEqual(4.1,  boxScore.AwayRB2Pts);
            Assert.AreEqual(4.4,  boxScore.AwayWR1Pts);
            Assert.AreEqual(12.6, boxScore.AwayWR2Pts);
            Assert.AreEqual(7.3,  boxScore.AwayTEPts);
            Assert.AreEqual(4.7,  boxScore.AwayFLEXPts);
            Assert.AreEqual(4,    boxScore.AwayDefensePts);
            Assert.AreEqual(11,   boxScore.AwayKPts);

            Assert.AreEqual(116.8, boxScore.HomeScore);
            Assert.AreEqual(91.4, boxScore.AwayScore);

            // test storing the data
            BoxScoreData.saveBoxScore(boxScore);
            var boxScore2 = BoxScoreData.getBoxScore(year, 1, erikId);
            Assert.AreEqual(5, boxScore2.TotalSacks);
            Assert.AreEqual(56, boxScore2.LongPunt);
            Assert.AreEqual("Dan Bailey", boxScore2.LongestFieldGoalKicker);
            Assert.AreEqual(32, boxScore2.LongestFieldGoal);
            Assert.AreEqual(14.3, boxScore2.HomeQBPts);
            Assert.AreEqual(12.4, boxScore2.HomeRB1Pts);
            Assert.AreEqual(13.1, boxScore2.HomeRB2Pts);
            Assert.AreEqual(4.8, boxScore2.HomeWR1Pts);
            Assert.AreEqual(13.2, boxScore2.HomeWR2Pts);
            Assert.AreEqual(12.3, boxScore2.HomeTEPts);
            Assert.AreEqual(10.7, boxScore2.HomeFLEXPts);
            Assert.AreEqual(27, boxScore2.HomeDefensePts);
            Assert.AreEqual(9, boxScore2.HomeKPts);
            Assert.AreEqual(27, boxScore2.MaxPlayerPoints);
            Assert.AreEqual("Panthers D/ST", boxScore2.MaxPlayerPointsPlayer);
            Assert.AreEqual("Panthers D/ST", boxScore2.HomeDefense);
            Assert.AreEqual(25, boxScore2.AwayQBPts);
            Assert.AreEqual(18.3, boxScore2.AwayRB1Pts);
            Assert.AreEqual(4.1, boxScore2.AwayRB2Pts);
            Assert.AreEqual(4.4, boxScore2.AwayWR1Pts);
            Assert.AreEqual(12.6, boxScore2.AwayWR2Pts);
            Assert.AreEqual(7.3, boxScore2.AwayTEPts);
            Assert.AreEqual(4.7, boxScore2.AwayFLEXPts);
            Assert.AreEqual(4, boxScore2.AwayDefensePts);
            Assert.AreEqual(11, boxScore2.AwayKPts);
            Assert.AreEqual(116.8, boxScore2.HomeScore);
            Assert.AreEqual(91.4, boxScore2.AwayScore);

            // week 2
            map.NavigateToUrl(getBoxScore(erikId, 2));
            boxScore = new BoxScore(map.getHtml(), erikId, 2, year);
            Assert.AreEqual(1, boxScore.TotalSacks);
            Assert.AreEqual(65, boxScore.LongPunt);
            Assert.AreEqual("Dan Bailey", boxScore.LongestFieldGoalKicker);
            Assert.AreEqual(28, boxScore.LongestFieldGoal);

            Assert.AreEqual(29.4, boxScore.HomeQBPts);
            Assert.AreEqual(6.2, boxScore.HomeRB1Pts);
            Assert.AreEqual(7.2, boxScore.HomeRB2Pts);
            Assert.AreEqual(14, boxScore.HomeWR1Pts);
            Assert.AreEqual(2.7, boxScore.HomeWR2Pts);
            Assert.AreEqual(8.2, boxScore.HomeTEPts);
            Assert.AreEqual(6.5, boxScore.HomeFLEXPts);
            Assert.AreEqual(6, boxScore.HomeDefensePts);
            Assert.AreEqual(8, boxScore.HomeKPts);
            Assert.AreEqual(29.4, boxScore.MaxPlayerPoints);
            Assert.AreEqual("Cam Newton", boxScore.MaxPlayerPointsPlayer);
            Assert.AreEqual("Panthers D/ST", boxScore.HomeDefense);

            Assert.AreEqual(14.7, boxScore.AwayQBPts);
            Assert.AreEqual(8, boxScore.AwayRB1Pts);
            Assert.AreEqual(14.7, boxScore.AwayRB2Pts);
            Assert.AreEqual(12.6, boxScore.AwayWR1Pts);
            Assert.AreEqual(5.8, boxScore.AwayWR2Pts);
            Assert.AreEqual(10.9, boxScore.AwayTEPts);
            Assert.AreEqual(8.3, boxScore.AwayFLEXPts);
            Assert.AreEqual(4, boxScore.AwayDefensePts);
            Assert.AreEqual(5, boxScore.AwayKPts);

            Assert.AreEqual(88.2, boxScore.HomeScore);
            Assert.AreEqual(83.9, boxScore.AwayScore);

            // week 9
            map.NavigateToUrl(getBoxScore(erikId, 9));
            boxScore = new BoxScore(map.getHtml(), erikId, 9, year);
            Assert.AreEqual(0, boxScore.AwayKPts);
        }
Exemplo n.º 3
0
        public void NavigateAllWeeks()
        {
            //var weeks = 14;
            var weeks = 12;
            initDictionaries();
            Trace.WriteLine("NavigateAllWeeks");
            var map = new FantasyFootballMap();
            for (int week = 1; week <= weeks; week++)
            {
                Trace.WriteLine(string.Format("Processing week {0}", week));
                foreach (var team in teams)
                {

                    Trace.WriteLine(string.Format("Processing team {0} in week {1}", team, week));
                    var boxScore = BoxScoreData.getBoxScore(year, week, team);
                    if (boxScore == null)
                    {
                        map.NavigateToUrl(getBoxScore(team, week));
                        boxScore = new BoxScore(map.getHtml(), team, week, year);
                        BoxScoreData.saveBoxScore(boxScore);
                    }

                    var fullBoxScore = BoxScoreData.getFullBoxScore(year, week, team);
                    if (fullBoxScore == null)
                    {
                        map.NavigateToUrl(getFullBoxScore(team, week));
                        fullBoxScore = new FullBoxScore(map.getHtml(), team, week, year);
                        BoxScoreData.saveFullBoxScore(fullBoxScore);
                    }

                    if (mostDefPts[team] == null || mostDefPts[team].HomeDefensePts < boxScore.HomeDefensePts)
                    {
                        mostDefPts[team] = boxScore;
                        Trace.WriteLine("Most def points: " + boxScore.HomeDefensePts);
                    }

                    if ((longestPunt[team] == null || longestPunt[team].LongPunt < boxScore.LongPunt))
                    {
                        longestPunt[team] = boxScore;
                        Trace.WriteLine("Longest punt: " + boxScore.LongPunt);
                    }

                    mostSacks[team] += boxScore.TotalSacks;
                    Trace.WriteLine("Total sacks: " + mostSacks[team]);

                    if (longestFGs[team] == null || longestFGs[team].LongestFieldGoal < boxScore.LongestFieldGoal)
                    {
                        longestFGs[team] = boxScore;
                        Trace.WriteLine(string.Format("Longest FG: {0} ({1})", boxScore.LongestFieldGoalKicker, boxScore.LongestFieldGoal));
                    }

                    if (mostCatches[team] == null || mostCatches[team].MostCatches < fullBoxScore.MostCatches)
                    {
                        mostCatches[team] = fullBoxScore;
                        Trace.WriteLine(string.Format("Most catches: {0} ({1})", mostCatches[team].MostCatchesPlayer, mostCatches[team].MostCatches));
                    }

                    if (mostRushes[team] == null || mostRushes[team].MostRushes < fullBoxScore.MostRushes)
                    {
                        mostRushes[team] = fullBoxScore;
                        Trace.WriteLine(string.Format("Most rushes: {0} ({1})", mostRushes[team].MostRushesPlayer, mostRushes[team].MostRushes));
                    }

                    var teamWon = boxScore.HomeScore > boxScore.AwayScore;
                    if (teamWon && (mostTOsInWin[team] == null || mostTOsInWin[team].Turnovers < fullBoxScore.Turnovers))
                    {
                        mostTOsInWin[team] = fullBoxScore;
                        Trace.WriteLine("Most TOs in a win: " + mostTOsInWin[team].Turnovers);
                    }

                    if (!teamWon && (mostPlyPoints[team] == null || mostPlyPoints[team].MaxPlayerPoints < boxScore.MaxPlayerPoints))
                    {
                        mostPlyPoints[team] = boxScore;
                        Trace.WriteLine(string.Format("Most player points in loss: {0} ({1}, wk{2})", mostPlyPoints[team].MaxPlayerPoints, mostPlyPoints[team].MaxPlayerPointsPlayer, mostPlyPoints[team].Week));
                    }

                    if (!teamWon && (mostTeamPtsInLoss[team] == null || mostTeamPtsInLoss[team].HomeScore < boxScore.HomeScore))
                    {
                        mostTeamPtsInLoss[team] = boxScore;
                        Trace.WriteLine(string.Format("Most team points in loss: {0} (wk{1})", mostTeamPtsInLoss[team].HomeScore, mostTeamPtsInLoss[team].Week));
                    }
                }
            }

            PrintSummary();
        }