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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void TestMoveRightCommandCorrect()
        {
            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("r");

            command.Execute(cmdContext);

            Assert.AreEqual(1, player.CurentCell.Position.Row);
            Assert.AreEqual(2, player.CurentCell.Position.Column);
        }
        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);
        }