Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void AddUpdateGameTeamTest()
        {
            Guid seedGameId = SeedGame();
            Guid seedTeamId = SeedTeam();

            GameTeamDto dto = new GameTeamDto()
            {
                GameId = seedGameId,
                TeamId = seedTeamId
            };

            var addResult = GameTeam.AddNew(dto);

            Assert.IsTrue(addResult.IsSuccess);

            var item = GameTeam.GetGameTeam(seedGameId, seedTeamId);

            Assert.IsNotNull(item);
            Assert.AreEqual(seedTeamId, item.TeamId);
            Assert.AreEqual(seedGameId, item.GameId);

            dto.GameTeamId = item.GameTeamId;
            dto.DeleteDate = DateTime.UtcNow;

            var updateResult = GameTeam.Update(dto);

            Assert.IsTrue(updateResult.IsSuccess);

            item = GameTeam.GetGameTeam(seedGameId, seedTeamId);
            Assert.IsNotNull(item);
            Assert.IsNotNull(item.DeleteDate);

            dto.DeleteDate = null;
            updateResult   = GameTeam.Update(dto);
            Assert.IsTrue(updateResult.IsSuccess);

            var items = GameTeam.GetGameTeams(seedGameId);

            Assert.IsTrue(items.Count >= 1);

            item = items.FirstOrDefault(x => x.TeamId == seedTeamId);
            Assert.IsNotNull(item);

            var removeResult = GameTeam.Remove(seedGameId, seedTeamId);

            Assert.IsTrue(removeResult.IsSuccess);

            item = GameTeam.GetGameTeam(seedGameId, seedTeamId);
            Assert.IsNull(item);

            DeleteSeededGame(seedGameId);
            DeleteSeededTeam(seedTeamId);
        }