public void MapToModel_Success() { Fixture f = new Fixture() { Id = 10, HomeTeamLeague = new TeamLeague(new League(), new Team("homeTeamName", "homeTeamNameLong"), "tlHomeTeamName", "tlHomeTeamNameLong"), AwayTeamLeague = new TeamLeague(new League(), new Team("awayTeamName", "awayTeamNameLong"), "tlAwayTeamName", "tlAwayTeamNameLong"), HomeTeamScore = 99, AwayTeamScore = 78, HasPlayerStats = "Y", Report = "123", IsPenaltyAllowed = true, }; model.MapToModel(f); Assert.That(model.FixtureId, Is.EqualTo(f.Id)); Assert.That(model.HomeTeamName, Is.EqualTo(f.HomeTeamLeague.TeamNameLong)); Assert.That(model.AwayTeamName, Is.EqualTo(f.AwayTeamLeague.TeamNameLong)); Assert.That(model.HomeTeamScore, Is.EqualTo(f.HomeTeamScore)); Assert.That(model.AwayTeamScore, Is.EqualTo(f.AwayTeamScore)); Assert.That(model.HasPlayerStats, Is.EqualTo(true)); Assert.That(model.Report, Is.EqualTo(f.Report)); Assert.That(model.IsPenaltyAllowed, Is.EqualTo(true)); }
public ActionResult Edit(int id) { Fixture fixture = null; User loggedInUser = membershipService.GetLoggedInUser(); // I don't particularly like this level of role checking, but I want to reuse this controller // for both roles so it'll do if (loggedInUser.SiteAdmin) { fixture = fixtureService.Get(id); } else { fixture = fixtureService.Get(id, loggedInUser.Team.Id); } if (fixture == null) { return(RedirectToAction("Index")); } MatchResultViewModel model = new MatchResultViewModel(); model.MapToModel(fixture); model.HomePlayerStats = model.MapToPlayerFixtureStats(this.statsReportingService.GetPlayerStatsForFixture(fixture.Id, fixture.HomeTeamLeague.Id), playerService.GetForTeam(fixture.HomeTeamLeague.Team.Id), fixture.HomeTeamLeague, fixture); model.AwayPlayerStats = model.MapToPlayerFixtureStats(this.statsReportingService.GetPlayerStatsForFixture(fixture.Id, fixture.AwayTeamLeague.Id), playerService.GetForTeam(fixture.AwayTeamLeague.Team.Id), fixture.AwayTeamLeague, fixture); return(View(model)); }