public static void saveFullBoxScore(FullBoxScore fullBoxScore) { var fileName = buildFilePath(fullBoxScore.Year, fullBoxScore.Week, fullBoxScore.TeamId, _typeFbs); var serializer = new XmlSerializer(typeof(FullBoxScore)); var writer = new StreamWriter(fileName); serializer.Serialize(writer, fullBoxScore); writer.Close(); }
public void RyanWeek1FullBox() { var week = 1; var map = new FantasyFootballMap(); map.NavigateToUrl(getFullBoxScore(ryanId, week)); var boxScore = new FullBoxScore(map.getHtml(), ryanId, week, year); Assert.AreEqual(2, boxScore.Turnovers); Assert.AreEqual(15, boxScore.MostCatches); Assert.AreEqual("Keenan Allen", boxScore.MostCatchesPlayer); Assert.AreEqual(12, boxScore.MostRushes); Assert.AreEqual("C.J. Anderson", boxScore.MostRushesPlayer); BoxScoreData.saveFullBoxScore(boxScore); var boxScore2 = BoxScoreData.getFullBoxScore(year, week, ryanId); Assert.IsNotNull(boxScore2); Assert.AreEqual(2, boxScore2.Turnovers); Assert.AreEqual(15, boxScore2.MostCatches); Assert.AreEqual("Keenan Allen", boxScore2.MostCatchesPlayer); Assert.AreEqual(12, boxScore2.MostRushes); Assert.AreEqual("C.J. Anderson", boxScore2.MostRushesPlayer); }
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(); }