Exemplo n.º 1
0
 public void TestGameControllerInstance()
 {
     ICellFactory factory = new GridCellFactory(4,4);
     IPlayField playField = new GridPlayField(factory, 4, 4);
     IGameRule rule = new ClassicRule();
     var controller = new GameController(playField, rule);
     Assert.IsNotNull(controller);
 }
Exemplo n.º 2
0
        public void TestGameFieldInitialization()
        {
            ICellFactory factory = new GridCellFactory(4, 4);
            IPlayField playField = new GridPlayField(factory, 4, 4);
            IGameRule rule = new ClassicRule();
            var controller = new GameController(playField, rule);
            string state = "0100111011001010";
            controller.SetState(state);

            Assert.AreEqual(controller.GetState(), state);
        }
Exemplo n.º 3
0
 public void TestNextGeneration()
 {
     ICellFactory factory = new GridCellFactory(4, 4);
     IPlayField playField = new GridPlayField(factory, 4, 4);
     IGameRule rule = new ClassicRule();
     var controller = new GameController(playField, rule);
     const string state = "0100010001000000"; // blinker 
     const string nextState = "0000111000000000";
     controller.SetState(state);
     controller.MoveToNextGeneration();
     Assert.AreEqual(nextState, controller.GetState());
 }
Exemplo n.º 4
0
 public void TestGameControllerInstanceNullPlayField()
 {
     try
     {
         IGameRule rule = new ClassicRule();
         var controller = new GameController(null, rule);
     }
     catch (Exception exception)
     {
         Assert.AreEqual("Value cannot be null.\r\nParameter name: playField", exception.Message);
         throw;
     }
 }
Exemplo n.º 5
0
        public void TestGameControllerInstanceNullGameRule()
        {
            try
            {
                ICellFactory factory = new GridCellFactory(4, 4);
                IPlayField playField = new GridPlayField(factory,4, 4);

                var controller = new GameController(playField, null);
            }
            catch (Exception exception)
            {
                Assert.AreEqual("Value cannot be null.\r\nParameter name: gameRule", exception.Message);
                throw;
            }
        }