public void CreateTest_Null() { //Arrange var baseRepo = new DataSeedService <object>(new TestClient()); //Act var val = baseRepo.Create(null); }
public TeamDetailPageTest() { Client = new TestClient(); var teamService = new DataSeedService <Team>(Client); var teamId = teamService.Create( new Team { Name = "TeamDetailPageTest" }); _viewModel = new TeamViewModel(teamService, teamId); }
public TournamentDetailPageTest() { Client = new TestClient(); var tournamentService = new DataSeedService <Tournament>(Client); var tournamentId = tournamentService.Create( new Tournament { Name = "TournamentDetailPageTest", Status = "Open" }); _viewModel = new TournamentViewModel(tournamentService, tournamentId); }
public Match AddMatch(string hometeamid, string awayteamid, string oversOrTournamentId, string location, string primaryumpire, string secondaryumpire) { var hometeam = _teamService.GetItem(hometeamid); if (hometeam == null) { throw new NullReferenceException("Home team name is not added"); } var awayteam = _teamService.GetItem(awayteamid); if (awayteam == null) { throw new NullReferenceException("Away team name is not added"); } int overs; string tournamentId = string.Empty; if (_isTournament) { tournamentId = oversOrTournamentId; overs = _tournamentService.GetItem(tournamentId).TotalOvers; } else { overs = int.Parse(oversOrTournamentId); } var match = new Match { HomeTeam = new TeamInning(), AddDate = DateTime.Now, AwayTeam = new TeamInning(), Location = location, PrimaryUmpire = primaryumpire, SecondaryUmpire = secondaryumpire, TotalOvers = overs }; var matchId = _matchService.Create(match); var matchIdKey = new KeyValuePair <string, string>("matchId", matchId); var tournamentIdKey = new KeyValuePair <string, string>("tournamentId", tournamentId); // Creating team innings and player innings and update match var teamInningService = new DataSeedService <TeamInning>(_client); var playerInningService = new DataSeedService <PlayerInning>(_client); var hometeaminningId = teamInningService.Create(new TeamInning { TeamName = hometeam.Name, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", hometeam.Id) }); foreach (var homeplayername in hometeam.Players) { var homeplayerinningId = playerInningService.Create(new PlayerInning { PlayerName = homeplayername, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", hometeam.Id), new KeyValuePair <string, string>("playerId", $"{hometeam.Id}:{homeplayername}") }); } var awayteaminningId = teamInningService.Create(new TeamInning { TeamName = awayteam.Name, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", awayteam.Id) }); foreach (var awayplayername in awayteam.Players) { var awayplayerinningId = playerInningService.Create(new PlayerInning { PlayerName = awayplayername, }, new KeyValuePair <string, string>[] { matchIdKey, tournamentIdKey, new KeyValuePair <string, string>("teamId", awayteam.Id), new KeyValuePair <string, string>("playerId", $"{awayteam.Id}:{awayplayername}") }); } //Update Match var updatematch = _matchService.GetItem(matchId); updatematch.HomeTeam = teamInningService.GetItem(hometeaminningId); updatematch.AwayTeam = teamInningService.GetItem(awayteaminningId); _matchService.Update(matchId, updatematch); return(updatematch); }