Exemplo n.º 1
0
        public void Apply_SetsStatusToDead_WhenCalled()
        {
            // Arrange
            CellInformation     info = CreateCellInformation();
            UnderpopulationRule sut  = CreateSut();

            // Act
            sut.Apply(info);

            // Assert
            info.Status.ShouldEqual(Cell.Status.Dead);
        }
Exemplo n.º 2
0
        public void Priority_ReturnsInteger_WhenCalled()
        {
            // Arrange
            CellInformation     info = CreateCellInformation();
            UnderpopulationRule sut  = CreateSut();

            // Act
            sut.Apply(info);

            // Assert
            sut.Priority.ShouldEqual(1);
        }
Exemplo n.º 3
0
        public void Initialize_AddsLessThanRule_WhenCalled()
        {
            // Arrange
            CellInformation     info = CreateCellInformation();
            UnderpopulationRule sut  = CreateSut();

            // Act
            sut.Initialize(info);

            // Assert
            sut.GetConditions().Last().ShouldBeInstanceOf <IsLessThan>();
        }
Exemplo n.º 4
0
        public void Initialize_AddsConditions_WhenCalled()
        {
            // Arrange
            CellInformation     info = CreateCellInformation();
            UnderpopulationRule sut  = CreateSut();

            // Act
            sut.Initialize(info);

            // Assert
            sut.GetConditions().Count().ShouldEqual(1);
        }
Exemplo n.º 5
0
        public void IsValid_ReturnsTrueOrFalse_ForGivenNeighbours(int neighbours,
                                                                  bool expected)
        {
            // Arrange
            CellInformation     info = CreateCellInformation(neighbours);
            UnderpopulationRule sut  = CreateSut();

            sut.Initialize(info);

            // Act
            bool actual = sut.IsValid();

            // Assert
            Assert.Equal(expected,
                         actual);
        }
Exemplo n.º 6
0
        public void Should_Test_UnderpopulationRule_Returns_False()
        {
            // arrange
            var fileInput = new FileReader();
            var grid      = new Universe(fileInput);
            var rule      = new UnderpopulationRule(grid);

            grid.SetUpGrid(Constants.GridLength, Constants.GridWidth);
            grid.Initialise();
            var col      = 1;
            var row      = 1;
            var expected = false;
            // act
            var result = rule.Check(row, col);

            // assert
            Assert.Equal(expected, result);
        }
Exemplo n.º 7
0
        public void Should_Test_UnderpopulationRule(int cellX, int cellY, bool expected)
        {
            // arrange
            var fileInput = new FileReader();
            var grid      = new Universe(fileInput);
            var rule      = new UnderpopulationRule(grid);

            grid.SetUpGrid(Constants.GridLength, Constants.GridWidth);
            grid.Initialise();
            grid.SwitchCellState(0, 0);
            grid.SwitchCellState(0, 1);
            grid.SwitchCellState(0, 2);
            grid.SwitchCellState(1, 0);
            grid.SwitchCellState(1, 2);
            grid.SwitchCellState(2, 0);
            grid.SwitchCellState(2, 1);
            // act
            var result = rule.Check(cellX, cellY);

            // assert
            Assert.Equal(expected, result);
        }
Exemplo n.º 8
0
        private UnderpopulationRule CreateSut()
        {
            var underpopulationRule = new UnderpopulationRule();

            return(underpopulationRule);
        }