예제 #1
0
        public void TestCreateCommandShouldReturnMoveDown()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("d");
            var received2      = commandFactory.CreateCommand("d");

            Assert.AreSame(received, received2);
        }
예제 #2
0
        public void TestUndoCommandGetCorrectName()
        {
            ICommandFactory factory = new SimpleCommandFactory();
            ICommand        command = factory.CreateCommand("undo");

            Assert.AreEqual("Undo", command.GetName());
        }
예제 #3
0
        public void TestRestartCommandGetCorrectName()
        {
            ICommandFactory factory = new SimpleCommandFactory();
            ICommand        command = factory.CreateCommand("restart");

            Assert.AreEqual("Restart", command.GetName());
        }
예제 #4
0
        public void TestScoreCommandGetCorrectName()
        {
            ICommandFactory factory = new SimpleCommandFactory();
            ICommand        command = factory.CreateCommand("top");

            Assert.AreEqual("Score", command.GetName());
        }
예제 #5
0
        public void TestMoveRightCommandGetCorrectName()
        {
            ICommandFactory factory = new SimpleCommandFactory();
            ICommand        command = factory.CreateCommand("r");

            Assert.AreEqual("Move Right", command.GetName());
        }
예제 #6
0
        public void TestCreateCommandShouldReturnUndo()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("undo");

            Assert.AreEqual(typeof(UndoCommand), received.GetType());
        }
예제 #7
0
        public void TestCreateCommandShouldReturnTop()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("top");

            Assert.AreEqual(typeof(ScoreCommand), received.GetType());
        }
예제 #8
0
        public void TestCreateCommandShouldReturnRestart()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("restart");

            Assert.AreEqual(typeof(RestartCommand), received.GetType());
        }
예제 #9
0
        public void TestCreateCommandShouldReturnMoveLeft()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("l");

            Assert.AreEqual(typeof(MoveLeft), received.GetType());
        }
예제 #10
0
        public void TestCreateCommandShouldReturnMoveDownFromDictionary()
        {
            var commandFactory = new SimpleCommandFactory();
            var received       = commandFactory.CreateCommand("d");

            Assert.AreEqual(typeof(MoveDown), received.GetType());
        }
예제 #11
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);
        }
예제 #12
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);
        }
예제 #13
0
 public void TestCreateCommandShouldReturnException()
 {
     var commandFactory = new SimpleCommandFactory();
     var received       = commandFactory.CreateCommand("dsadsadas");
 }