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);
        }
        public void GameNextInningTeamTest()
        {
            Guid teamOneId = SeedTeam();
            Guid teamTwoId = SeedTeamTwo();

            var teamOne = Team.GetTeam(teamOneId);
            var teamTwo = Team.GetTeam(teamTwoId);

            Assert.IsNotNull(teamOne);
            Assert.IsNotNull(teamTwo);

            Guid gameId = SeedGame();

            Guid gtOneId = SeedGameTeam(gameId, teamOne.TeamId, battingSequence: 0);
            Guid gtTwoId = SeedGameTeam(gameId, teamTwo.TeamId, battingSequence: 1);

            GameInningDto gameInningDto = new GameInningDto()
            {
                InningNumber = 1,
                GameId       = gameId,
                GameInningId = Guid.NewGuid()
            };

            GameInning.AddNew(gameInningDto);

            Guid?nextTeamId = GameInningTeam.GetNextAtBatTeamId(gameId);

            Assert.AreEqual(nextTeamId, teamOne.TeamId);

            GameInningTeamDto dto = new GameInningTeamDto()
            {
                GameInningTeamId = Guid.NewGuid(),
                GameTeamId       = gtOneId,
                GameInningId     = gameInningDto.GameInningId,
                Outs             = 0,
                Score            = 0
            };

            GameInningTeam.AddNew(dto);

            nextTeamId = GameInningTeam.GetNextAtBatTeamId(gameId);
            Assert.AreEqual(nextTeamId, teamTwo.TeamId);

            gameInningDto.InningNumber = 2;
            gameInningDto.GameInningId = Guid.NewGuid();
            GameInning.AddNew(gameInningDto);

            nextTeamId = GameInningTeam.GetNextAtBatTeamId(gameId);
            Assert.AreEqual(teamOne.TeamId, nextTeamId);

            DeleteSeededGame(gameId);
            DeleteSeededTeam(teamOneId);
            DeleteSeededTeam(teamTwoId);
        }
Exemple #3
0
        public Guid SeedGameInning()
        {
            Guid gameInningId = Guid.NewGuid();
            Guid seedGameId   = SeedGame();

            GameInningDto dto = new GameInningDto()
            {
                GameInningId = gameInningId,
                GameId       = seedGameId,
                InningNumber = 1
            };

            GameInning.AddNew(dto);

            return(gameInningId);
        }