Ejemplo n.º 1
0
        public void DeadCell_MoreThan3LiveNeighbors_StaysDead([Range(4, 8)] int liveNeighbors)
        {
            var       currentState = CellState.Dead;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Dead, newState);
        }
Ejemplo n.º 2
0
 public GameOfLife(int width, int height, int maxGenerations)
 {
     _world          = new World(width, height);
     _rules          = new VirusRules();
     _maxGenerations = maxGenerations;
     _currentGen     = 0;
 }
Ejemplo n.º 3
0
        public void DeadCell_WithFewerThan3LiveNeighbors_StaysDead(int liveNeighbors)
        {
            var       currentState = CellState.Dead;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.Equal(CellState.Dead, newState);
        }
Ejemplo n.º 4
0
        public void LiveCell_2Or3LiveNeighbors_Lives([Values(2, 3)] int liveNeighbors)
        {
            var       currentState = CellState.Alive;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Alive, newState);
        }
Ejemplo n.º 5
0
        public void LiveCell_FewerThan2LiveNeighbors_Dies([Values(0, 1)] int liveNeighbors)
        {
            var       currentState = CellState.Alive;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Dead, newState);
        }
Ejemplo n.º 6
0
        public void LiveCell_MoreThan3Neighbors_Dies([Range(4, 8)] int liveNeighbors)
        {
            var       currentState = CellState.Alive;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Dead, newState);
        }
Ejemplo n.º 7
0
        public void CurrentState_When2_ThrowsArgumentException()
        {
            var currentState  = (CellState)2;
            var liveNeighbors = 0;

            Assert.Throws <ArgumentOutOfRangeException>(() => LifeRules.GetNewState(currentState, liveNeighbors));
        }
Ejemplo n.º 8
0
        public void DeadCell_FewerThan3LiveNeighbors_StaysDead([Values(0, 1, 2)] int liveNeighbors)
        {
            var       currentState = CellState.Dead;
            CellState newState     = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Dead, newState);
        }
Ejemplo n.º 9
0
        public void DeadCell_ExactlyThreeLiveNeighbours_BecomesLiveByReproduction()
        {
            Cellstate currentState  = Cellstate.Dead;
            int       liveNeghbours = 3;
            Cellstate result        = LifeRules.GetNewState(currentState, liveNeghbours);

            Assert.AreEqual(Cellstate.Alive, result);
        }
Ejemplo n.º 10
0
        public void LiveCell_MoreThanThreeLiveNeighbours_DiesByOverpopulation()
        {
            Cellstate currentState  = Cellstate.Alive;
            int       liveNeghbours = 4;
            Cellstate result        = LifeRules.GetNewState(currentState, liveNeghbours);

            Assert.AreEqual(Cellstate.Dead, result);
        }
Ejemplo n.º 11
0
        public void LiveCell_TwoOrThreeLiveNeighbours_LivestoNextGeneration()
        {
            Cellstate currentState  = Cellstate.Alive;
            int       liveNeghbours = 3;
            Cellstate result        = LifeRules.GetNewState(currentState, liveNeghbours);

            Assert.AreEqual(Cellstate.Alive, result);
        }
Ejemplo n.º 12
0
        public void AnyLiveCellWithFewerthanTwoLiveNeighborsDiesAsIfByUnderPopulation()
        {
            Cellstate currentState   = Cellstate.Alive;
            int       liveNeighbours = 1;
            Cellstate result         = LifeRules.GetNewState(currentState, liveNeighbours);

            Assert.AreEqual(Cellstate.Dead, result);
        }
Ejemplo n.º 13
0
        public void DeadCell_Exactly3LiveNeighbors_Lives()
        {
            int       liveNeighbors = 3;
            var       currentState  = CellState.Dead;
            CellState newState      = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Alive, newState);
        }
Ejemplo n.º 14
0
        public void LiveCell_TwoOrThreeLiveNeighbors_Lives(CellState currentState, int liveNeighbors)
        {
            // Act
            var result = LifeRules.GetNewState(currentState, liveNeighbors);

            // Assert
            Assert.Equal(CellState.Alive, result);
        }
Ejemplo n.º 15
0
        public void LiveCell_LessThan2Neighbours_Die(int liveNeighbours)
        {
            CellState currentState = CellState.Alive;

            CellState nextState = LifeRules.GetNextState(currentState, liveNeighbours);

            Assert.AreEqual(CellState.Dead, nextState);
        }
Ejemplo n.º 16
0
        public void DeadCell_ExactlyThreeLiveNeighbors_Lives([Values(3)] int liveNeighbors)
        {
            var currentState = CellState.Dead;

            CellState newState = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.AreEqual(CellState.Alive, newState);
        }
Ejemplo n.º 17
0
        public void DeadCell_WithThreeNeighbours_Live(int liveNeighbours)
        {
            CellState currentState = CellState.Dead;

            CellState nextState = LifeRules.GetNextState(currentState, liveNeighbours);

            Assert.AreEqual(CellState.Alive, nextState);
        }
Ejemplo n.º 18
0
        public void DeadCell_NotExactlyThreeLiveNeighbors_Dead(CellState currentState, int liveNeighbors)
        {
            // Act
            var result = LifeRules.GetNewState(currentState, liveNeighbors);

            // Assert
            Assert.Equal(CellState.Dead, result);
        }
Ejemplo n.º 19
0
        public void LiveCell_MoreThanThreeLiveNeighbors_Dies(CellState currentState, int liveNeighbors)
        {
            // Act
            var result = LifeRules.GetNewState(currentState, liveNeighbors);

            // Assert
            Assert.Equal(CellState.Dead, result);
        }
Ejemplo n.º 20
0
        public void LiveCell_FewerThan2LiveNeighbours_Dies()
        {
            var currentState   = CellState.Alive;
            var liveNeighbours = 0;

            CellState newState = LifeRules.GetNewState(currentState, liveNeighbours);

            Assert.AreEqual(CellState.Dead, newState);
        }
Ejemplo n.º 21
0
        public void DeadCell_WithMoreThenThreeNeighbours_Die
            ([Range(4, 8)] int liveNeighbours)
        {
            CellState currentState = CellState.Dead;

            CellState nextState = LifeRules.GetNextState(currentState, liveNeighbours);

            Assert.AreEqual(CellState.Dead, nextState);
        }
Ejemplo n.º 22
0
 public void DeadCell_FewerThan3LiveNeighbors_StaysDead([Range(0, 2)] int liveNeighbors)
 {
     //Arrange
     var currentState = CellState.Dead;
     // Act
     CellState newState = LifeRules.GetNewState(currentState, liveNeighbors);
     // Assert
     Assert.AreEqual(CellState.Dead, newState);
 }
Ejemplo n.º 23
0
        public void DeadCell_With3LiveNeighbors_BecomesAlive()
        {
            var liveNeighbors = 3;
            var currentState  = CellState.Dead;

            CellState newState = LifeRules.GetNewState(currentState, liveNeighbors);

            Assert.Equal(CellState.Alive, newState);
        }
Ejemplo n.º 24
0
        public void LiveNeighbors_LessThan0_ThrowsArgumentException()
        {
            var currentState  = CellState.Alive;
            int liveNeighbors = -1;
            var paramName     = "liveNeighbors";

            Assert.Throws <ArgumentOutOfRangeException>(
                paramName,
                () => LifeRules.GetNewState(currentState, liveNeighbors));
        }
Ejemplo n.º 25
0
        public void LiveNeighbours_InvalidValues_ThrowsArgumentException([Values(-1, 9)] int liveNeighbours)
        {
            // Arrange
            CellState currentState = CellState.Alive;

            // Assert
            Assert.Throws(Is.TypeOf <ArgumentOutOfRangeException>().And.Property("ParamName").EqualTo(nameof(liveNeighbours))
                          // Act
                          , () => LifeRules.GetNewState(currentState, liveNeighbours));
        }
Ejemplo n.º 26
0
        public void CurrentState_UndefinedValue_ThrowsArgumentException([Values(-1, 2)] CellState currentState)
        {
            // Arrange
            int liveNeighbours = 0;
            // Act
            var e = Assert.Throws <ArgumentOutOfRangeException>(() => LifeRules.GetNewState(currentState, liveNeighbours));

            // Assert
            Assert.AreEqual(e.ParamName, nameof(currentState));
        }
Ejemplo n.º 27
0
        public void CurrentState_When2_ThrowsArgumentException()
        {
            var currentState  = (CellState)2;
            int liveNeighbors = 2;

            var exception = Record.Exception(() => LifeRules.GetNewState(currentState, liveNeighbors));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentOutOfRangeException>(exception);
        }
            public void Live_Cell_With_More_Than_Three_Neighbors_Dies(string currentState, int numberOfLiveNeighbors)
            {
                // Any live cell with more than three neighbors dies

                //Act
                string newState = LifeRules.GetNewState(currentState, numberOfLiveNeighbors);

                //Assert
                Assert.AreEqual("dead", newState);
            }
            public void Live_Cell_With_Two_Or_Three_Live_Neighbors_Lives(string currentState, int numberOfLiveNeighbors)
            {
                // Any live cell with two or three live neighbors lives

                //Act
                string newState = LifeRules.GetNewState(currentState, numberOfLiveNeighbors);

                //Assert
                Assert.AreEqual("alive", newState);
            }
Ejemplo n.º 30
0
 public void DeadCell_Exactly3LiveNeighbors_Lives()
 {
     //Arrange
     var currentState = CellState.Dead;
     var liveNeighbors = 3;
     // Act
     CellState newState = LifeRules.GetNewState(currentState, liveNeighbors);
     // Assert
     Assert.AreEqual(CellState.Alive, newState);
 }
Ejemplo n.º 31
0
 public Game(GameBoard board, TextBlock generationDisplay, LifeRules rules)
 {
     _board = board;
     _generationDisplay = generationDisplay;
     _rules = rules;
 }