public void SettingCellStateIsIdempotent()
        {
            var aPosition = new Mock<IPosition>();
            var universe = new StateHolder();

            universe.SetState(aPosition.Object, new Alive());
            Assert.Equal(new Alive(), universe.GetState(aPosition.Object));

            universe.SetState(aPosition.Object, new Alive());
            Assert.Equal(new Alive(), universe.GetState(aPosition.Object));
        }
        public void TheUniverseHoldsCellStates()
        {
            var aPosition = new Mock<IPosition>();
            var anotherPosition = new Mock<IPosition>();
            var universe = new StateHolder();

            universe.SetState(aPosition.Object, new Alive());
            universe.SetState(anotherPosition.Object, new Dead());

            Assert.Equal(new Alive(), universe.GetState(aPosition.Object));
            Assert.Equal(new Dead(), universe.GetState(anotherPosition.Object));
        }
        public void AStateNotSetMeansDead()
        {
            var aPosition = new Mock<IPosition>();
            var universe = new StateHolder();

            Assert.Equal(new Dead(), universe.GetState(aPosition.Object));
        }
        public void FourAliveCellsStayAlive()
        {
            var p00 = new CartesianPosition(0, 0);
            var p01 = new CartesianPosition(0, 1);
            var p11 = new CartesianPosition(1, 1);
            var p10 = new CartesianPosition(1, 0);

            var stateHolder = new StateHolder();
            stateHolder.SetState(p00, new Alive());
            stateHolder.SetState(p01, new Alive());
            stateHolder.SetState(p11, new Alive());
            stateHolder.SetState(p10, new Alive());

            var engine = new Engine<CartesianPosition>(stateHolder, new CartesianSpaceLimits());
            var secondGeneration = engine.NextGeneration();

            Assert.Equal(new Alive(), stateHolder.GetState(p00));
            Assert.Equal(new Alive(), stateHolder.GetState(p01));
            Assert.Equal(new Alive(), stateHolder.GetState(p11));
            Assert.Equal(new Alive(), stateHolder.GetState(p10));
        }