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); }
public void NextGameInningTeamBatterTest() { //seed teams Guid teamOneId = SeedTeam(); Guid teamTwoId = SeedTeamTwo(); //seed players Guid playerOneId = SeedPlayer(); Guid playerTwoId = SeedPlayerTwo(); Guid playerThreeId = SeedPlayerThree(); Guid playerFourId = SeedPlayerFour(); //seed team lineups List <Guid> teamOneLineup = new List <Guid> { playerOneId, playerTwoId, playerThreeId, playerFourId }; SeedTeamPlayerLineup(teamOneId, teamOneLineup); List <Guid> teamTwoLineup = new List <Guid> { playerFourId, playerThreeId, playerTwoId, playerOneId }; SeedTeamPlayerLineup(teamTwoId, teamTwoLineup); //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); //see if the first player in the linup is selected Guid?nextBatterId = GameInningTeamBatter.GetNextGameBatterPlayerId(gameId, teamOneId); Assert.AreEqual(nextBatterId, playerOneId); GameInningTeamBatterDto gameInningTeamBatterDto = new GameInningTeamBatterDto() { GameInningTeamId = gameInningTeamDto.GameInningTeamId, PlayerId = playerOneId, EventType = (int)EventType.Out, GameInningTeamBatterId = Guid.NewGuid(), Sequence = 0 }; GameInningTeamBatter.AddNew(gameInningTeamBatterDto); //see if the second player in the lineup is selected nextBatterId = GameInningTeamBatter.GetNextGameBatterPlayerId(gameId, teamOneId); Assert.AreEqual(nextBatterId, playerTwoId); GameInningTeamBatterDto gameInningTeamBatter2Dto = new GameInningTeamBatterDto() { GameInningTeamId = gameInningTeamDto.GameInningTeamId, PlayerId = playerTwoId, EventType = (int)EventType.Single, GameInningTeamBatterId = Guid.NewGuid(), Sequence = 1 }; GameInningTeamBatter.AddNew(gameInningTeamBatter2Dto); //see if the thrid batter is selected nextBatterId = GameInningTeamBatter.GetNextGameBatterPlayerId(gameId, teamOneId); Assert.AreEqual(nextBatterId, playerThreeId); GameInningTeamBatterDto gameInningTeamBatter3Dto = new GameInningTeamBatterDto() { GameInningTeamId = gameInningTeamDto.GameInningTeamId, PlayerId = playerThreeId, EventType = (int)EventType.Single, GameInningTeamBatterId = Guid.NewGuid(), Sequence = 2 }; GameInningTeamBatter.AddNew(gameInningTeamBatter3Dto); //see if fourth batter is selected nextBatterId = GameInningTeamBatter.GetNextGameBatterPlayerId(gameId, teamOneId); Assert.AreEqual(nextBatterId, playerFourId); GameInningTeamBatterDto gameInningTeamBatter4Dto = new GameInningTeamBatterDto() { GameInningTeamId = gameInningTeamDto.GameInningTeamId, PlayerId = playerFourId, EventType = (int)EventType.Single, GameInningTeamBatterId = Guid.NewGuid(), Sequence = 3 }; GameInningTeamBatter.AddNew(gameInningTeamBatter4Dto); //see if first batter is up again nextBatterId = GameInningTeamBatter.GetNextGameBatterPlayerId(gameId, teamOneId); Assert.AreEqual(nextBatterId, playerOneId); //cleanup test data DeleteSeededTeam(teamOneId); DeleteSeededTeam(teamTwoId); DeleteSeededTeamPlayerLineup(teamOneId); DeleteSeededTeamPlayerLineup(teamTwoId); DeleteSeededGame(gameId); DeleteSeededPlayer(playerOneId); DeleteSeededPlayer(playerTwoId); DeleteSeededPlayer(playerThreeId); DeleteSeededPlayer(playerFourId); }