Beispiel #1
0
        public void FindAlive_ReturnsEmpty_ForAllDead()
        {
            // Arrange
            Dictionary <int, ICells> rows = CreateEmptyRows();
            NeighboursFinder         sut  = CreateSut();

            // Act
            int actual = sut.NumberOfAliveNeighbours(rows,
                                                     0,
                                                     0);

            // Assert
            actual.ShouldEqual(0);
        }
Beispiel #2
0
        public void FindAlive_ReturnsOne_ForOnlyOneIsAlive(int row,
                                                           int column)
        {
            // Arrange
            Dictionary <int, ICells> rows = CreateEmptyRows();
            var cells = new Cells();

            cells.SetStatus(column,
                            Cell.Status.Alive);
            rows.Add(row,
                     cells);

            NeighboursFinder sut = CreateSut();

            // Act
            int actual = sut.NumberOfAliveNeighbours(rows,
                                                     0,
                                                     0);

            // Assert
            actual.ShouldEqual(1);
        }
Beispiel #3
0
        public void FindAlive_ReturnsTwo_ForTwoAreAlive()
        {
            // Arrange
            Dictionary <int, ICells> rows = CreateEmptyRows();
            var cells = new Cells();

            cells.SetStatus(0,
                            Cell.Status.Alive);
            cells.SetStatus(-1,
                            Cell.Status.Alive);
            rows.Add(-1,
                     cells);

            NeighboursFinder sut = CreateSut();

            // Act
            int actual = sut.NumberOfAliveNeighbours(rows,
                                                     0,
                                                     0);

            // Assert
            actual.ShouldEqual(2);
        }