Example #1
0
        public void Can_Create_Grid()
        {
            //arrange
            var cellsState = new[, ] {
                { 0, 0, 0, 1 }, { 1, 1, 0, 1 }, { 1, 0, 1, 1 }, { 1, 1, 0, 0 }
            };

            //act

            var grid = GridFactory.CreateBoundaryLessGrid(cellsState);


            //assert
            Assert.IsNotNull(grid);
        }
        public void Can_Display_Grid()
        {
            //arrange
            var cellsState = new[, ] {
                { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
            };
            var grid = GridFactory.CreateBoundaryLessGrid(cellsState);

            //act

            var strigToTest = grid.ToString();

            //assert

            Assert.AreEqual("....\n....\n....\n....\n", strigToTest);
        }
Example #3
0
        public void Should_Continue_For_4_Times_Given_The_State()
        {
            //arrange

            var cellsState = new[, ] {
                { 0, 0, 0, 1 }, { 1, 1, 0, 1 }, { 1, 0, 1, 1 }, { 1, 1, 0, 0 }
            };
            var gameRules = new GameRules();

            var grid = GridFactory.CreateBoundaryLessGrid(cellsState);
            var consoleOperations = new Mock <ICommunicationOperations>();

            //act

            var game = new Game(consoleOperations.Object, grid, gameRules);

            game.Start();


            //assert

            consoleOperations.Verify(
                m => m.WriteLine("...*\n**.*\n*.**\n**..\n"));

            consoleOperations.Verify(
                m => m.WriteLine(It.Is <string>(c =>
                                                c == "...*\n.*..\n....\n.*..\n")));

            consoleOperations.Verify(
                m => m.WriteLine(It.Is <string>(c =>
                                                c == "*.*.\n....\n....\n....\n")));

            consoleOperations.Verify(
                m => m.WriteLine(It.Is <string>(c =>
                                                c == "....\n....\n....\n....\n")));
        }