public void ReadData() { var file = @"C:\Users\u0158158\Documents\VS\Tennis\2012TennisOdds.xlsx"; var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"{0}\"; Extended Properties=\"Excel 12.0; IMEX=1; HDR=YES\";", file); var adapter = new OleDbDataAdapter("SELECT * FROM [TennisOdds$]", connectionString); using (var ds = new DataSet()) { adapter.Fill(ds, "TennisOdds"); this.excelMatches = ds.Tables["TennisOdds"].AsEnumerable(); } foreach (var match in this.excelMatches) { var predictionURL = new Uri(match.Field <string>("URL").Replace(".", "").Replace("’", "").Replace("'", "").Replace("&", "").Replace(",", "").RemoveDiacritics()); var jsonTennisPrediction = (APITennisPrediction)this.webRepository.ParseJson <APITennisPrediction>( predictionURL, s => ProgressReporterProvider.Current.ReportProgress(s, Model.ReporterImportance.Low, Model.ReporterAudience.Admin)); var genericPrediction = TennisPredictionStrategy.ConvertAPIToGeneric(jsonTennisPrediction, predictionURL); genericPrediction.MatchDate = match.Field <DateTime>("DateToTake").Date; if (!this.predictions.ContainsKey(match.Field <string>("URL"))) { this.predictions.Add(match.Field <string>("URL"), genericPrediction); } } }
public void CreatesACollectionOfPredictionsForTodaysMatches() { //Arrange matchDate = new DateTime(2013, 02, 06); this.webRepositoryProvider = new ManifestWebRepositoryProvider(); this.mockFixtureRepository = BuildFixtureRepository.Create(); this.mockPredictionRepository = BuildPredictionRepository.Create() .HasTodaysMatchesURL(); var predictionStrategy = new TennisPredictionStrategy(this.mockPredictionRepository.Object, this.mockFixtureRepository.Object, this.webRepositoryProvider); var valueOptions = new Model.ValueOptions() { Sport = new E.Sport { SportName = "Tennis" }, OddsSource = new E.ExternalSource { Source = "Not relevant" }, CouponDate = matchDate, Tournament = new E.Tournament { TournamentName = "Not relevant" } }; //Act var genericPredictions = predictionStrategy.FetchPredictions(valueOptions); //Assert Assert.AreEqual(18, genericPredictions.Count()); genericPredictions.ToList().ForEach(x => { Assert.AreEqual(x.OutcomeProbabilities.Sum(o => o.Value), 1.0, 0.01); }); //spot check Assert.AreEqual(1, genericPredictions.Count(x => x.TeamOrPlayerA == "Ramos" && x.TeamOrPlayerB == "Dutra Silva")); Assert.AreEqual(1, genericPredictions.Count(x => x.TeamOrPlayerA == "Sousa" && x.TeamOrPlayerB == "Gimeno-Traver")); Assert.AreEqual(1, genericPredictions.Count(x => x.TeamOrPlayerA == "Davydenko" && x.TeamOrPlayerB == "Nieminen")); }