public void DeleteSeededGame(Guid gameId) { var game = Game.GetGame(gameId); Guid leagueId = game.LeagueId; foreach (var gi in GameInning.GetGameInnings(gameId)) { foreach (var git in GameInningTeam.GetInningTeams(gi.GameInningId)) { foreach (var gitb in GameInningTeamBatter.GetGameInningTeamBatters(git.GameInningTeamId)) { GameInningTeamBatter.Remove(gitb.GameInningTeamId, gitb.Sequence); } GameInningTeam.Remove(git.GameInningId, git.GameTeamId); } GameInning.Remove(gi.GameId, gi.InningNumber); } foreach (var item in GameTeam.GetGameTeams(gameId)) { GameTeam.Remove(item.GameId, item.TeamId); } Game.Remove(gameId); League.RemoveLeague(leagueId); }
public void AddUpdateGameInningTeamBatterTest() { Guid seedGameInningTeamId = SeedGameInningTeam(); Guid seedPlayerId = SeedPlayer(); GameInningTeamBatterDto dto = new GameInningTeamBatterDto() { GameInningTeamId = seedGameInningTeamId, PlayerId = seedPlayerId, Sequence = TEST_SEQUENCE, EventType = TEST_EVENT_TYPE, TargetEventType = TEST_TARGET_EVENT_TYPE, RBIs = TEST_RBIS }; var addResult = Service.AddNew(dto); Assert.IsTrue(addResult.IsSuccess); var item = Service.GetGameInningTeamBatter(seedGameInningTeamId, TEST_SEQUENCE); Assert.IsNotNull(item); Assert.AreEqual(item.GameInningTeamId, seedGameInningTeamId); Assert.AreEqual(item.PlayerId, seedPlayerId); Assert.AreEqual(item.Sequence, TEST_SEQUENCE); Assert.AreEqual(item.RBIs, TEST_RBIS); Assert.AreEqual(item.EventType, TEST_EVENT_TYPE); Assert.AreEqual(item.TargetEventType, TEST_TARGET_EVENT_TYPE); dto.GameInningTeamBatterId = item.GameInningTeamBatterId; dto.RBIs = TEST_RBIS_2; dto.EventType = TEST_EVENT_TYPE_2; dto.TargetEventType = TEST_TARGET_EVENT_TYPE_2; var updateResult = Service.Update(dto); Assert.IsTrue(updateResult.IsSuccess); var inningAtBats = Service.GetGameInningTeamBatters(seedGameInningTeamId); Assert.IsTrue(inningAtBats.Count > 0); item = inningAtBats.FirstOrDefault(x => x.Sequence == TEST_SEQUENCE); Assert.IsNotNull(item); Assert.AreEqual(item.GameInningTeamId, seedGameInningTeamId); Assert.AreEqual(item.PlayerId, seedPlayerId); Assert.AreEqual(item.Sequence, TEST_SEQUENCE); Assert.AreEqual(item.RBIs, TEST_RBIS_2); Assert.AreEqual(item.EventType, TEST_EVENT_TYPE_2); Assert.AreEqual(item.TargetEventType, TEST_TARGET_EVENT_TYPE_2); var removeResult = Service.Remove(seedGameInningTeamId, TEST_SEQUENCE); Assert.IsTrue(removeResult.IsSuccess); item = Service.GetGameInningTeamBatter(seedGameInningTeamId, TEST_SEQUENCE); Assert.IsNull(item); DeleteSeededGameInningTeam(seedGameInningTeamId); DeleteSeededPlayer(seedPlayerId); }