public void TestPlayerCurrentCellGetterShouldReturnCorrectCell() { ICell cell = new Cell(new Position(1,3)); IPlayer player = new Player("Test", cell); ICell actualCell = player.CurentCell; Assert.AreSame(cell,actualCell); }
/// <summary> /// Method that start the main logic of the game. /// </summary> /// <param name="output">Output renderer</param> /// <param name="input">Iput provider</param> /// <param name="cmmandLogger">Command logger</param> public static void Start(IRenderer output, IInputProvider input, ILogger cmmandLogger) { output.ShowInfoMessage("Please ente your name: "); string playerName = input.GetPlayerName(); output.ShowInfoMessage("Please enter a dimension for the board the standard is 9x9"); int dimension = input.GetPlayFieldDimensions(); ICell playerCell = new Cell(new Position(dimension / 2, dimension / 2)); IPlayField playField = null; var player = new Player.Player(playerName, playerCell); try { var playFieldGenerator = new StandardPlayFieldGenerator(player.CurentCell.Position, dimension, dimension); playField = new PlayField.PlayField(playFieldGenerator, player.CurentCell.Position, dimension, dimension); } catch (ArgumentOutOfRangeException e) { output.ShowInfoMessage(e.Message); } ICommandFactory commandFactory = new SimpleCommandFactory(); IMementoCaretaker memory = new MementoCaretaker(new List <IMemento>()); IScoreLadder ladder = ScoreLadder.Instance; IGameEngine gameEngine = new StandardGameEngine(output, input, playField, commandFactory, cmmandLogger, player, memory, ladder); gameEngine.Initialize(RandomNumberGenerator.Instance); gameEngine.Start(); }
/// <summary> /// Method that start the main logic of the game. /// </summary> /// <param name="output">Output renderer</param> /// <param name="input">Iput provider</param> /// <param name="cmmandLogger">Command logger</param> public static void Start(IRenderer output, IInputProvider input, ILogger cmmandLogger) { output.ShowInfoMessage("Please ente your name: "); string playerName = input.GetPlayerName(); output.ShowInfoMessage("Please enter a dimension for the board the standard is 9x9"); int dimension = input.GetPlayFieldDimensions(); ICell playerCell = new Cell(new Position(dimension / 2, dimension / 2)); IPlayField playField = null; var player = new Player.Player(playerName, playerCell); try { var playFieldGenerator = new StandardPlayFieldGenerator(player.CurentCell.Position, dimension, dimension); playField = new PlayField.PlayField(playFieldGenerator, player.CurentCell.Position, dimension, dimension); } catch (ArgumentOutOfRangeException e) { output.ShowInfoMessage(e.Message); } ICommandFactory commandFactory = new SimpleCommandFactory(); IMementoCaretaker memory = new MementoCaretaker(new List<IMemento>()); IScoreLadder ladder = ScoreLadder.Instance; IGameEngine gameEngine = new StandardGameEngine(output, input, playField, commandFactory, cmmandLogger, player,memory,ladder); gameEngine.Initialize(RandomNumberGenerator.Instance); gameEngine.Start(); }
public void TestMovePlayerOnCorrectPosition() { IPlayField playField = new PlayField(new PlayFldGen(new Position(1, 1)), new Position(1, 1)); playField.InitializePlayFieldCells(RandomNumberGenerator.Instance); IPlayer player = new Player("Test", playField.GetCell(new Position(1, 1))); playField.RemovePlayer(player); playField.AddPlayer(player, new Position(1,2)); Assert.AreEqual(player.CurentCell.Position.Row,playField.PlayerPosition.Row); Assert.AreEqual(player.CurentCell.Position.Column, playField.PlayerPosition.Column); }
public void TestMovePlayerOnIncorrectPositionShouldThrow() { PlayFldGen generator = new PlayFldGen(new Position(1, 1)); IPlayField playField = new PlayField(generator, new Position(1, 1)); playField.InitializePlayFieldCells(RandomNumberGenerator.Instance); generator.ChangeCellAtPosition(new Position(1, 2), Constants.StandardGameCellWallValue); IPlayer player = new Player("Test", playField.GetCell(new Position(1, 1))); playField.RemovePlayer(player); playField.AddPlayer(player, new Position(1, 2)); }
public void TestMoveLeftCommandCorrect() { IPlayFieldGenerator pg = new PlayFieldGenerator(); IPlayField playFld = new PlayField(pg, new Position(1, 1), 3, 3); playFld.InitializePlayFieldCells(RandomNumberGenerator.Instance); Mock<IRenderer> mockRenderer = new Mock<IRenderer>(); IMementoCaretaker mockMemento = new MementoCaretaker(new List<IMemento>()); Mock<IScoreLadder> mockScoreLader = new Mock<IScoreLadder>(); IPlayer player = new Player("Test", new Cell(new Position(1, 1), Constants.StandardGamePlayerChar)); ICommandContext cmdContext = new CommandContext(playFld, mockRenderer.Object, mockMemento, mockScoreLader.Object, player); ICommandFactory factory = new SimpleCommandFactory(); ICommand command = factory.CreateCommand("l"); command.Execute(cmdContext); Assert.AreEqual(1, player.CurentCell.Position.Row); Assert.AreEqual(0, player.CurentCell.Position.Column); }
public void TestPlayerWithNullNameShouldThrow() { IPlayer player = new Player(null,new Cell(new Position(1,3))); }
public void TestPlayerWithNullCellShouldThrow() { IPlayer player = new Player("Test1",null); }
public void TestPlayerWithEmptyStringNameShouldThrow() { IPlayer player = new Player("",new Cell(new Position(1,3))); }
public void TestPlayerWithCorrectNameAndCell() { IPlayer player = new Player("Test",new Cell(new Position(1,3))); }
public void TestPlayerNameGetterShouldReturnCorrectName() { IPlayer player = new Player("Test",new Cell(new Position(1,4))); string expected = "Test"; Assert.AreEqual(player.Name,expected); }
public void TestScoreCommandCorrect() { IPlayFieldGenerator pg = new PlayFieldGenerator(); IPlayField playFld = new PlayField(pg, new Position(1, 1), 3, 3); playFld.InitializePlayFieldCells(RandomNumberGenerator.Instance); Mock<IRenderer> mockRenderer = new Mock<IRenderer>(); IMementoCaretaker mockMemento = new MementoCaretaker(new List<IMemento>()); Mock<IScoreLadder> mockScoreLader = new Mock<IScoreLadder>(); IPlayer player = new Player("Test", new Cell(new Position(1, 1), Constants.StandardGamePlayerChar)); ICommandContext cmdContext = new CommandContext(playFld, mockRenderer.Object, mockMemento, mockScoreLader.Object, player); ICommandFactory factory = new SimpleCommandFactory(); ICommand command = factory.CreateCommand("top"); command.Execute(cmdContext); mockRenderer.Verify(x => x.ShowScoreLadder(It.IsAny<IScoreLadderContentProvider>()), Times.Once); }