Beispiel #1
0
        private void LiveCellWithMoreThanThreeNeighboursDies_Wrapping()
        {
            var grid = new Grid(3, 3);

            // #  #
            //    #
            //    #  #
            grid.SetCellAliveAtCoords(new[] { 1, 1 });
            grid.SetCellAliveAtCoords(new[] { 2, 1 });
            grid.SetCellAliveAtCoords(new[] { 2, 2 });
            grid.SetCellAliveAtCoords(new[] { 2, 3 });
            grid.SetCellAliveAtCoords(new[] { 3, 3 });

            var game = new Game(grid);

            game.ProgressTime();

            const string expected = "         \n" +
                                    "         \n" +
                                    "         \n";

            var actual = GridFormatter.OutputWithoutGridLinesAndNumbers(grid);

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        private void CorrectOutputWhenApplyingAllRulesSimultaneously_Wrapping()
        {
            var grid = new Grid(3, 3);

            // #  #
            // #  #
            // #    #

            grid.SetCellAliveAtCoords(new[] { 1, 1 });
            grid.SetCellAliveAtCoords(new[] { 2, 1 });
            grid.SetCellAliveAtCoords(new[] { 1, 2 });
            grid.SetCellAliveAtCoords(new[] { 2, 2 });
            grid.SetCellAliveAtCoords(new[] { 1, 3 });
            grid.SetCellAliveAtCoords(new[] { 3, 3 });

            var game = new Game(grid);

            game.ProgressTime();

            const string expected = "         \n" +
                                    "         \n" +
                                    "         \n";

            var actual = GridFormatter.OutputWithoutGridLinesAndNumbers(grid);

            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        private void DeadCellWithThreeLivesNeighboursBecomesAlive()
        {
            var grid = new Grid(4, 4);

            //
            //    #  #
            //    #
            //
            grid.SetCellAliveAtCoords(new[] { 2, 2 });
            grid.SetCellAliveAtCoords(new[] { 3, 2 });
            grid.SetCellAliveAtCoords(new[] { 2, 3 });

            var game = new Game(grid);

            game.ProgressTime();

            const string expected = "            \n" +
                                    "    #  #    \n" +
                                    "    #  #    \n" +
                                    "            \n";

            var actual = GridFormatter.OutputWithoutGridLinesAndNumbers(grid);

            Assert.Equal(expected, actual);
        }
Beispiel #4
0
        private void CorrectOutputForXKCDRipJohnConwayPattern()
        {
            var grid = new Grid(8, 11);

            //
            //          #  #  #
            //          #     #
            //          #     #
            //             #
            //    #     #  #  #
            //       #     #     #
            //             #        #
            //          #     #
            //          #     #

            grid.SetCellAliveAtCoords(new[] { 4, 3 });
            grid.SetCellAliveAtCoords(new[] { 5, 3 });
            grid.SetCellAliveAtCoords(new[] { 6, 3 });
            grid.SetCellAliveAtCoords(new[] { 4, 4 });
            grid.SetCellAliveAtCoords(new[] { 6, 4 });
            grid.SetCellAliveAtCoords(new[] { 4, 5 });
            grid.SetCellAliveAtCoords(new[] { 6, 5 });
            grid.SetCellAliveAtCoords(new[] { 5, 6 });
            grid.SetCellAliveAtCoords(new[] { 2, 7 });
            grid.SetCellAliveAtCoords(new[] { 4, 7 });
            grid.SetCellAliveAtCoords(new[] { 5, 7 });
            grid.SetCellAliveAtCoords(new[] { 6, 7 });
            grid.SetCellAliveAtCoords(new[] { 3, 8 });
            grid.SetCellAliveAtCoords(new[] { 5, 8 });
            grid.SetCellAliveAtCoords(new[] { 7, 8 });
            grid.SetCellAliveAtCoords(new[] { 5, 9 });
            grid.SetCellAliveAtCoords(new[] { 8, 9 });
            grid.SetCellAliveAtCoords(new[] { 4, 10 });
            grid.SetCellAliveAtCoords(new[] { 6, 10 });
            grid.SetCellAliveAtCoords(new[] { 4, 11 });
            grid.SetCellAliveAtCoords(new[] { 6, 11 });

            var game = new Game(grid);

            game.ProgressTime();

            const string expected = "                        \n" +
                                    "             #          \n" +
                                    "          #     #       \n" +
                                    "       #  #     #  #    \n" +
                                    "          #     #       \n" +
                                    "       #                \n" +
                                    "       #                \n" +
                                    "       #           #    \n" +
                                    "             #     #    \n" +
                                    "          #     #  #    \n" +
                                    "                        \n";

            var actual = GridFormatter.OutputWithoutGridLinesAndNumbers(grid);

            Assert.Equal(expected, actual);
        }
        public void OutputsEmptyGridForNewGrid()
        {
            var          grid     = new Grid(3, 3);
            const string expected = "         \n" +
                                    "         \n" +
                                    "         \n";

            var actual = GridFormatter.OutputWithoutGridLinesAndNumbers(grid);

            Assert.Equal(expected, actual);
        }