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 AddUpdateGameInningTest() { Guid seedGameId = SeedGame(); GameInningDto dto = new GameInningDto() { GameId = seedGameId, InningNumber = TEST_INNING_NUMBER }; var addResult = GameInning.AddNew(dto); Assert.IsTrue(addResult.IsSuccess); var item = GameInning.GetGameInning(seedGameId, TEST_INNING_NUMBER); Assert.IsNotNull(item); Assert.AreEqual(seedGameId, item.GameId); Assert.AreEqual(TEST_INNING_NUMBER, item.InningNumber); dto.InningNumber = 4; addResult = GameInning.AddNew(dto); Assert.IsTrue(addResult.IsSuccess); item = GameInning.GetGameInning(seedGameId, inningNumber: 4); dto.GameInningId = item.GameInningId; dto.DeleteDate = DateTime.UtcNow; var updateResult = GameInning.Update(dto); Assert.IsTrue(updateResult.IsSuccess); item = GameInning.GetGameInning(seedGameId, inningNumber: 4); Assert.IsNotNull(item); Assert.IsNotNull(item.DeleteDate); dto.DeleteDate = null; updateResult = GameInning.Update(dto); Assert.IsTrue(updateResult.IsSuccess); item = GameInning.GetGameInning(seedGameId, inningNumber: 4); Assert.IsNotNull(item); Assert.IsNull(item.DeleteDate); var items = GameInning.GetGameInnings(seedGameId); Assert.IsTrue(items.Count >= 1); foreach (var i in items) { var removeResult = GameInning.Remove(i.GameId, i.InningNumber); Assert.IsTrue(removeResult.IsSuccess); } items = GameInning.GetGameInnings(seedGameId); Assert.IsTrue(items.Count == 0); DeleteSeededGame(seedGameId); }