Пример #1
0
 public void FillCurrentAtBatTeamPlayer()
 {
     if (CurrentGameInning != null && CurrentGameInningTeam != null)
     {
         CurrentGameInningTeamBatter = new Models.GameInningTeamBatter(GameInningTeamBatter.GetCurrentGameInningTeamBatter(GameId));
         CurrentPlayer = new Models.Player(AllPlayers.FirstOrDefault(y => y.PlayerId == CurrentGameInningTeamBatter.PlayerId));
     }
 }
Пример #2
0
        public void GameInningTeamBatterCurrentBatterTest()
        {
            //seed teams
            Guid teamOneId = SeedTeam();
            Guid teamTwoId = SeedTeamTwo();

            //seed players
            Guid playerOneId   = SeedPlayer();
            Guid playerTwoId   = SeedPlayerTwo();
            Guid playerThreeId = SeedPlayerThree();
            Guid playerFourId  = SeedPlayerFour();

            //seed game
            Guid gameId        = SeedGame();
            Guid gameTeamOneId = SeedGameTeam(gameId, teamOneId, battingSequence: 0);
            Guid gameTeamTwoId = SeedGameTeam(gameId, teamTwoId, battingSequence: 1);

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

            GameInning.AddNew(gameInningDto);

            GameInningTeamDto gameInningTeamDto = new GameInningTeamDto()
            {
                GameTeamId       = gameTeamOneId,
                GameInningId     = gameInningDto.GameInningId,
                GameInningTeamId = Guid.NewGuid()
            };

            GameInningTeam.AddNew(gameInningTeamDto);


            GameInningTeamBatterDto gameInningTeamBatterDto = new GameInningTeamBatterDto()
            {
                GameInningTeamId       = gameInningTeamDto.GameInningTeamId,
                PlayerId               = playerOneId,
                EventType              = (int)EventType.Out,
                GameInningTeamBatterId = Guid.NewGuid(),
                Sequence               = 0
            };

            GameInningTeamBatter.AddNew(gameInningTeamBatterDto);

            var currentBatter = GameInningTeamBatter.GetCurrentGameInningTeamBatter(gameId);

            Assert.IsNotNull(currentBatter);
            Assert.AreEqual(playerOneId, currentBatter.PlayerId);

            GameInningTeamBatterDto gameInningTeamBatter2Dto = new GameInningTeamBatterDto()
            {
                GameInningTeamId       = gameInningTeamDto.GameInningTeamId,
                PlayerId               = playerTwoId,
                EventType              = (int)EventType.Single,
                GameInningTeamBatterId = Guid.NewGuid(),
                Sequence               = 1
            };

            GameInningTeamBatter.AddNew(gameInningTeamBatter2Dto);

            currentBatter = GameInningTeamBatter.GetCurrentGameInningTeamBatter(gameId);
            Assert.IsNotNull(currentBatter);
            Assert.AreEqual(currentBatter.PlayerId, playerTwoId);

            //cleanup test data
            DeleteSeededTeam(teamOneId);
            DeleteSeededTeam(teamTwoId);
            DeleteSeededGame(gameId);
            DeleteSeededPlayer(playerOneId);
            DeleteSeededPlayer(playerTwoId);
            DeleteSeededPlayer(playerThreeId);
            DeleteSeededPlayer(playerFourId);
        }