Esempio 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);
 }
Esempio 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);
        }
Esempio 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());
 }
Esempio 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;
     }
 }
Esempio 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;
            }
        }