public void BasicTransitionTest_SingleCellLives()
        {
            bool[,] startingPoint =
            {
                { false, false, false },
                { true,  true,  true  },
                { false, false, false }
            };

            bool[,] expected =
            {
                { false, true, false },
                { false, true, false },
                { false, true, false }
            };


            ICellTransition _trans = new CellTransitionImpl();

            bool[,] result = _trans.ApplyTransition(startingPoint);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(expected[i, j], result[i, j]);
                }
            }
        }
        public void BasicTransitionTest_SameSizeInVsOut()
        {
            bool[,] startingPoint =
            {
                { false, false, false },
                { false, true,  false },
                { false, false, false }
            };

            ICellTransition _trans = new CellTransitionImpl();

            bool[,] result = _trans.ApplyTransition(startingPoint);



            Assert.AreEqual(startingPoint.GetLongLength(0), result.GetLongLength(0));
            Assert.AreEqual(startingPoint.GetLongLength(1), result.GetLongLength(1));

            try
            {
                startingPoint.GetLongLength(2); //Should throw exception because we are not expected a new dim.
                Assert.Fail("Unexpected LongLength");
            }
            catch (Exception)
            {
                //Passes test.
            }
        }
Ejemplo n.º 3
0
        public Main()
        {
            InitializeComponent();

            _cti = new CellTransitionImpl();

            //The following progresses the generations and mutates the cells over time.
            // This is an event handler which is attached to the OnTick event of a Timer.
            this.grid1.GenerationTimer.Tick += delegate(object s, EventArgs e1)
            {
                this.grid1.GridBits = _cti.ApplyTransition(this.grid1.GridBits);
                this.lblGenNum.Text = (generation++).ToString();
            };
        }