public void Clear_RGBGridWithLiveCells_AllCellsBecomeDead()
        {
            var grid = new RGBGrid(4, false);

            var coords = new Dictionary <Point, State>
            {
                { new Point {
                      X = 1, Y = 1
                  }, State.RED },
                { new Point {
                      X = 1, Y = 2
                  }, State.GREEN },
                { new Point {
                      X = 3, Y = 3
                  }, State.BLUE }
            };

            grid.SetInitialCells(coords);

            int deadCellsBefore = GridTestHelper.GetStateCount(grid, State.DEAD);

            Assert.AreEqual(deadCellsBefore, 13);

            grid.Clear();

            var deadCellsAfter = GridTestHelper.GetStateCount(grid, State.DEAD);

            Assert.AreEqual(deadCellsAfter, grid.Data.Length);
        }
        public void SetInitialCells_EmptyRGBGrid_OnlyChosenCellsStateChanged()
        {
            var grid = new RGBGrid(4, false);

            int deadCellsBefore = GridTestHelper.GetStateCount(grid, State.DEAD);

            Assert.AreEqual(deadCellsBefore, grid.Data.Length);

            // set chosen cells
            var coords = new Dictionary <Point, State>
            {
                { new Point {
                      X = 1, Y = 1
                  }, State.RED },
                { new Point {
                      X = 1, Y = 2
                  }, State.GREEN },
                { new Point {
                      X = 1, Y = 3
                  }, State.BLUE },
            };

            grid.SetInitialCells(coords);

            int redCellsAfter   = GridTestHelper.GetStateCount(grid, State.RED);
            int greenCellsAfter = GridTestHelper.GetStateCount(grid, State.GREEN);
            int blueCellsAfter  = GridTestHelper.GetStateCount(grid, State.BLUE);
            int deadCellsAfter  = GridTestHelper.GetStateCount(grid, State.DEAD);

            Assert.AreEqual(redCellsAfter, 1);
            Assert.AreEqual(greenCellsAfter, 1);
            Assert.AreEqual(blueCellsAfter, 1);
            Assert.AreEqual(deadCellsAfter, 13);
        }
        public void SetInitialCells_EmptyRGBGrid_CorrectlySetsChosenCellsStates()
        {
            var grid = new RGBGrid(4, false);

            Assert.IsTrue(grid.Data[1, 1].CurrentState == State.DEAD);
            Assert.IsTrue(grid.Data[2, 1].CurrentState == State.DEAD);
            Assert.IsTrue(grid.Data[3, 1].CurrentState == State.DEAD);

            // Set chosen cells
            var coords = new Dictionary <Point, State>
            {
                { new Point {
                      X = 1, Y = 1
                  }, State.RED },
                { new Point {
                      X = 1, Y = 2
                  }, State.GREEN },
                { new Point {
                      X = 1, Y = 3
                  }, State.BLUE },
            };

            grid.SetInitialCells(coords);

            Assert.IsTrue(grid.Data[1, 1].CurrentState == State.RED);
            Assert.IsTrue(grid.Data[2, 1].CurrentState == State.GREEN);
            Assert.IsTrue(grid.Data[3, 1].CurrentState == State.BLUE);
        }
        public void SetInitialCells_EmptyRGBGrid_ThrowsForCellCoordsOutOfRange()
        {
            var grid = new RGBGrid(4, false);

            var coords = new Dictionary <Point, State> {
                { new Point {
                      X = 5, Y = 5
                  }, State.RED }
            };

            grid.SetInitialCells(coords);
        }