public void SeedACoupleOfFixtures() { var teamRepository = new TeamRepository(new Commands()); var divisionRepository = new DivisionRepository(new Commands()); var fixtureRepository = new FixtureRepository(new Commands()); var championship = divisionRepository.GetByIdentifier("E2"); if (championship == null) { championship = new Division { DivisionIdentifier = "E2", Name = "Championship" }; divisionRepository.Save(championship); } teamRepository.SaveNewTeam("Brighton", championship); var brighton = teamRepository.LoadTeamByName("Brighton"); teamRepository.SaveNewTeam("West Ham", championship); var westHam = teamRepository.LoadTeamByName("West Ham"); var fixture = new Fixture { HomeTeam = brighton, AwayTeam = westHam, Date = DateTime.Parse("23/10/2011") }; fixtureRepository.Save(fixture); }
public void SaveNewTeam(string teamName, Division division) { using (var context = new ScoreSquidContext()) { commands.SaveNewTeam(context, teamName, division); } }
public void Save(Division division) { using (var context = new ScoreSquidContext()) { commands.SaveDivison(context, division); } }
protected Team CreateTeam(string teamName, Division division, ITeamRepository teamRepository) { var team = teamRepository.LoadTeamByName(teamName); if (team == null) { teamRepository.SaveNewTeam(teamName, division); team = teamRepository.LoadTeamByName(teamName); } return team; }
public void SaveNewTeam(ScoreSquidContext context, string teamName, Division division) { Team team = new Team { Name = teamName, Division = division }; context.Teams.Add(team); context.Save(); }
public void SaveDivison(ScoreSquidContext context, Division division) { context.Divisions.Add(division); context.Save(); }
public void TestResultImporter_ShouldImportResultsFromFile() { string[] csvlines = File.ReadAllLines(@"C:\Projects\ScoreSquid\csv\E2.csv"); Division division = new Division { Name = "Championship", DivisionIdentifier = "E2" }; var results = (from csvline in csvlines.Skip(1) let data = csvline.Split(',') select new { Date = data[1], HomeTeam = data[2], AwayTeam = data[3], HomeTeamFullTimeTeamGoals = data[4], AwayTeamFullTimeTeamGoals = data[5], FullTimeResult = data[6], HomeTeamHalfTimeTeamGoals = data[7], AwayTeamHalfTimeTeamGoals = data[8], HalfTimeResult = data[9], HomeTotalShots = data[11], AwayTotalShots = data[12], HomeShotsOnTarget = data[13], AwayShotsOnTarget = data[14], HomeFouls = data[15], AwayFouls = data[16], HomeCorners = data[17], AwayCorners = data[18], HomeYellowCards = data[19], AwayYellowCards = data[20], HomeRedCards = data[21], AwayRedCards = data[22] }).ToList(); foreach (var result in results) { var homeTeam = CreateTeam(result.HomeTeam, division); var awayTeam = CreateTeam(result.AwayTeam, division); var matchResult = new Result { FullTimeResult = result.FullTimeResult, HalfTimeResult = result.HalfTimeResult, HomeTeam_Corners = result.HomeCorners.TryIntParse(), HomeTeam_FoulsCommitted = result.HomeFouls.TryIntParse(), HomeTeam_FullTimeTeamGoals = result.HomeTeamFullTimeTeamGoals.TryIntParse(), HomeTeam_HalfTimeTeamGoals = result.HomeTeamHalfTimeTeamGoals.TryIntParse(), HomeTeam_RedCards = result.HomeRedCards.TryIntParse(), HomeTeam_ShotsOnTarget = result.HomeShotsOnTarget.TryIntParse(), HomeTeam_TotalShots = result.HomeTotalShots.TryIntParse(), HomeTeam_YellowCards = result.HomeYellowCards.TryIntParse(), AwayTeam_Corners = result.AwayCorners.TryIntParse(), AwayTeam_FoulsCommitted = result.AwayFouls.TryIntParse(), AwayTeam_FullTimeTeamGoals = result.AwayTeamFullTimeTeamGoals.TryIntParse(), AwayTeam_HalfTimeTeamGoals = result.AwayTeamHalfTimeTeamGoals.TryIntParse(), AwayTeam_RedCards = result.AwayRedCards.TryIntParse(), AwayTeam_ShotsOnTarget = result.AwayShotsOnTarget.TryIntParse(), AwayTeam_TotalShots = result.AwayTotalShots.TryIntParse(), AwayTeam_YellowCards = result.AwayYellowCards.TryIntParse() }; var fixture = fixtureRepository.GetByHomeTeamNameAndAwayTeamName(result.HomeTeam, result.AwayTeam); if (fixture == null) { fixture = new Fixture(); fixture.HomeTeam = homeTeam; fixture.AwayTeam = awayTeam; fixture.Date = result.Date.TryDateParse(); fixture.Result.Add(matchResult); } fixtureRepository.Save(fixture); } Assert.IsTrue(results.Count > 0); }