コード例 #1
0
        public void GetNeighbourStates_EdgeCellLeft_Has5Neighbours()
        {
            var grid     = new RGBGrid(4, false);
            var edgeCell = grid.Data[2, 0];

            var neighbours = new NeighbourStates(grid, edgeCell);
            var states     = neighbours.GetNeighbourStates();

            Assert.IsTrue(states.Count() == 5);
        }
コード例 #2
0
        public void GetNeighbourStates_InteriorCell3_Has8Neighbours()
        {
            var grid         = new RGBGrid(4, false);
            var interiorCell = grid.Data[2, 2];

            var neighbours = new NeighbourStates(grid, interiorCell);
            var states     = neighbours.GetNeighbourStates();

            Assert.IsTrue(states.Count() == 8);
        }
コード例 #3
0
        public void GetNeighbourStates_CornerCellBottomRight_Has3Neighbours()
        {
            var grid       = new RGBGrid(4, false);
            var cornerCell = grid.Data[3, 3];

            var neighbours = new NeighbourStates(grid, cornerCell);
            var states     = neighbours.GetNeighbourStates();

            Assert.IsTrue(states.Count() == 3);
        }
コード例 #4
0
        public void GetNeighbourStates__InteriorCell_2_2_InFilledGrid__Neighbours3Red2Green3Blue()
        {
            var grid = NeighbourStatesTestHelper.MakeFilled4x4RGBGrid();
            var cell = grid.Data[2, 2];

            var neighbours   = new NeighbourStates(grid, cell);
            var actualStates = neighbours.GetNeighbourStates();

            var actualStateCounts   = NeighbourStatesTestHelper.GetStateCountsDict(actualStates);
            var expectedStateCounts = new Dictionary <State, int> {
                { State.RED, 3 }, { State.GREEN, 2 }, { State.BLUE, 3 },
            };

            Assert.IsTrue(NeighbourStatesTestHelper.DictsAreEqual(actualStateCounts, expectedStateCounts));
        }
コード例 #5
0
        public void GetNeighbourStates_EdgeCellLeftInFilledGrid_Neighbours2Dead3Red()
        {
            var grid = NeighbourStatesTestHelper.MakeFilled4x4RGBGrid();
            var cell = grid.Data[2, 0];

            var neighbours   = new NeighbourStates(grid, cell);
            var actualStates = neighbours.GetNeighbourStates();

            var actualStateCounts   = NeighbourStatesTestHelper.GetStateCountsDict(actualStates);
            var expectedStateCounts = new Dictionary <State, int> {
                { State.DEAD, 2 }, { State.RED, 3 }
            };

            Assert.IsTrue(NeighbourStatesTestHelper.DictsAreEqual(actualStateCounts, expectedStateCounts));
        }
コード例 #6
0
        public void GetNeighbourStates_EdgeCellTopInFilledGrid_Neighbours2Red1Green2Blue()
        {
            var grid = NeighbourStatesTestHelper.MakeFilled4x4RGBGrid();
            var cell = grid.Data[0, 2];

            var neighbours   = new NeighbourStates(grid, cell);
            var actualStates = neighbours.GetNeighbourStates();

            var actualStateCounts   = NeighbourStatesTestHelper.GetStateCountsDict(actualStates);
            var expectedStateCounts = new Dictionary <State, int> {
                { State.BLUE, 2 }, { State.GREEN, 1 }, { State.RED, 2 }
            };

            Assert.IsTrue(NeighbourStatesTestHelper.DictsAreEqual(actualStateCounts, expectedStateCounts));
        }
コード例 #7
0
        public void GetNeighbourStates_CornerCellBottomRightInFilledGrid_Neighbours1Blue2Green()
        {
            var grid = NeighbourStatesTestHelper.MakeFilled4x4RGBGrid();
            var cell = grid.Data[3, 3];

            var neighbours   = new NeighbourStates(grid, cell);
            var actualStates = neighbours.GetNeighbourStates();

            var actualStateCounts   = NeighbourStatesTestHelper.GetStateCountsDict(actualStates);
            var expectedStateCounts = new Dictionary <State, int> {
                { State.BLUE, 1 }, { State.GREEN, 2 }
            };

            Assert.IsTrue(NeighbourStatesTestHelper.DictsAreEqual(actualStateCounts, expectedStateCounts));
        }
コード例 #8
0
        public void GetNeighbourStates_InteriorCellInEmptyGrid_HasAllDeadNeighbours()
        {
            var grid = new RGBGrid(4, false);
            var cell = grid.Data[2, 2];

            var neighbours   = new NeighbourStates(grid, cell);
            var actualStates = neighbours.GetNeighbourStates();

            var actualStateCounts   = NeighbourStatesTestHelper.GetStateCountsDict(actualStates);
            var expectedStateCounts = new Dictionary <State, int> {
                { State.DEAD, 8 }
            };

            Assert.IsTrue(NeighbourStatesTestHelper.DictsAreEqual(actualStateCounts, expectedStateCounts));
        }