public void WillPassPlayerTypeToClassHandler() { Mock <PlayerClassHandler> mockHandler = new Mock <PlayerClassHandler>(MockBehavior.Strict); mockHandler.Setup(x => x.createPlayer((PlayerType)1000)).Returns((Player)null).Verifiable(); service = new PlayerCreationService(mockHandler.Object); service.createPlayer((PlayerType)1000); mockHandler.Verify(); }
public IActionResult makeMove([FromBody] BoardGameDTO gameDto) { BoardGame game = boardCreationService.createBoardGame(gameDto); Player player = playerCreationService.createPlayer(gameDto.cur); List <Player> players = playerCreationService.createPlayers(gameDto.players); return(ExecuteApiAction(() => new ApiResult <BoardGameDTO> { Model = gameService.processMove(game, player, players) })); }
public void WillReturnThePlayerReturnedFromTheHandler() { Mock <Player> mockPlayer = new Mock <Player>(); Mock <PlayerClassHandler> mockHandler = new Mock <PlayerClassHandler>(MockBehavior.Strict); mockHandler.Setup(x => x.createPlayer((PlayerType)1000)).Returns(mockPlayer.Object).Verifiable(); service = new PlayerCreationService(mockHandler.Object); Player result = service.createPlayer((PlayerType)1000); Assert.AreEqual(mockPlayer.Object, result); }
public void WillReturnThePlayerReturnedFromTheHandlerFromAJObject() { JObject player = new JObject(); player.Add("type", 1000); player.Add("name", ""); player.Add("colour", 1000); player.Add("userId", 0); Mock <Player> mockPlayer = new Mock <Player>(); Mock <PlayerClassHandler> mockHandler = new Mock <PlayerClassHandler>(MockBehavior.Strict); mockHandler.Setup(x => x.createPlayer((PlayerType)1000)).Returns(mockPlayer.Object).Verifiable(); service = new PlayerCreationService(mockHandler.Object); Player result = service.createPlayer(player); Assert.AreEqual(mockPlayer.Object, result); }
public void WillCallPlayerHandlerWithTheTypeFromTheJObject() { JObject player = new JObject(); player.Add("type", 1000); player.Add("name", ""); player.Add("colour", 1000); player.Add("userId", 0); Mock <PlayerClassHandler> mockHandler = new Mock <PlayerClassHandler>(MockBehavior.Strict); mockHandler.Setup(x => x.createPlayer((PlayerType)1000)) .Returns(new Mock <Player>().Object) .Verifiable(); service = new PlayerCreationService(mockHandler.Object); service.createPlayer(player); mockHandler.Verify(); }
public void WillSetTheNameOfThePlayer() { JObject player = new JObject(); player.Add("type", 1000); player.Add("name", "some silly name"); player.Add("colour", 100); player.Add("userId", 0); Mock <PlayerClassHandler> mockHandler = new Mock <PlayerClassHandler>(); Mock <Player> mockPlayer = new Mock <Player>(MockBehavior.Loose); mockPlayer.Setup(x => x.setName("some silly name")).Verifiable(); mockHandler.Setup(x => x.createPlayer((PlayerType)1000)).Returns(mockPlayer.Object); service = new PlayerCreationService(mockHandler.Object); service.createPlayer(player); mockPlayer.Verify(); }
public void WillReturnNullIfNullIsPassedIn() { Player result = service.createPlayer(null); Assert.IsNull(result); }