コード例 #1
0
 public Form1()
 {
     InitializeComponent();
     timer1.Interval = 500;
     _currentBoard   = new Board(0, 0);
     _gameOL         = new GameOfLife();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: preox/KataGameOfLife
        static void Main(string[] args)
        {
            /*
             * Very, very simple tester. Mostly for the sake of visualization.
             *
             */
            Console.WriteLine("===================");

            LifeGrid grid = new LifeGrid(new char[,] {
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '*', '.', '.', '.'  },
                    { '.', '.', '.', '*', '*', '.', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  }
                    });

            GameOfLife test = new GameOfLife(grid);

            test.printGrid();
            test.produceNextGeneration();
            test.printGrid();

            Console.WriteLine("===================");

            grid = new LifeGrid(new char[,] {
                { '*', '.', '.', '.'  },
                { '.', '.', '.', '.'  },
                { '.', '*', '.', '.'  },
                { '.', '.', '.', '.'  }
            }) ;

            test.GameGrid = grid;

            test.printGrid();
            test.produceNextGeneration();
            test.printGrid();

            Console.WriteLine("===================");

            grid = new LifeGrid(new char[,] {
                { '*', '*', '.', '.' , '.' },
                { '.', '.', '.', '.' , '.' },
                { '.', '*', '.', '.' , '.' }
            });

            test.GameGrid = grid;
            test.printGrid();
            test.produceNextGeneration();
            test.printGrid();
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: preox/KataGameOfLife
        public void TestOutput1()
        {
            // Test input and output as given in task text
            GameOfLife localSut = new GameOfLife(new LifeGrid(new char[,] {
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '*', '.', '.', '.'  },
                    { '.', '.', '.', '*', '*', '.', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  }
                    }));

            LifeGrid expectedResult = new LifeGrid(  new char[,] {
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '*', '*', '.', '.', '.'  },
                    { '.', '.', '.', '*', '*', '.', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  }
                    });

            localSut.produceNextGeneration();

            Assert.IsTrue(localSut.GameGrid.compareGrid(expectedResult));
        }
コード例 #4
0
ファイル: TestGame.cs プロジェクト: stardawg/STL-Coding-Dojo
 public void setupTest()
 {
     target = new GameOfLife();
 }
コード例 #5
0
ファイル: TestGame.cs プロジェクト: stardawg/STL-Coding-Dojo
        public void ICanGetTheLoadedBoard()
        {
            var target = new GameOfLife();

            target.Load(kataBoardWith4RowsOf8Columns);

            Assert.AreEqual(kataBoardWith4RowsOf8Columns, target.Board);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: huwyss/KataCatalog
 public Form1(GameOfLife gol)
 {
     _gol = gol;
     InitializeComponent();
 }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: preox/KataGameOfLife
        public void TestOutput2()
        {
            // Testing a few more patterns and expected results i found on the intertube.
            GameOfLife localSut = new GameOfLife(new LifeGrid(new char[,] {
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '*', '.', '.', '.', '.', '.', '.'  },
                    { '*', '*', '*', '.', '.', '.', '.', '.'  },
                    { '.', '*', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '*', '*', '.', '.'  },
                    { '.', '.', '.', '.', '*', '*', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  }
                    }));

            LifeGrid expectedResult = new LifeGrid(  new char[,] {
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '*', '*', '*', '.', '.', '.', '.', '.'  },
                    { '*', '.', '*', '.', '.', '.', '.', '.'  },
                    { '*', '*', '*', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  },
                    { '.', '.', '.', '.', '*', '*', '.', '.'  },
                    { '.', '.', '.', '.', '*', '*', '.', '.'  },
                    { '.', '.', '.', '.', '.', '.', '.', '.'  }
                    });

            localSut.produceNextGeneration();

            Assert.IsTrue(localSut.GameGrid.compareGrid(expectedResult));
        }