Exemplo n.º 1
0
 public void TestIfResetMethodCorrectlyResetsTheUserMovesCount()
 {
     var gameModel = new Game(new GameLogic(MatrixValidator.GetInstance));
     gameModel.IncrementMoves();
     gameModel.Reset();
     Assert.AreEqual(0, gameModel.UserMovesCount);
 }
Exemplo n.º 2
0
        public static void Main()
        {
            var consoleUI = new ConsoleUI();
            var commandFactory = new CommandFactory();
            var gameLogicProvider = new GameLogic(MatrixValidator.GetInstance);
            var gameModel = new Game(gameLogicProvider);

            var engine = new Engine(consoleUI, UserInputValidator.GetInstance, commandFactory, gameModel, gameLogicProvider);
            engine.Run();
        }
Exemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var graphicUi = new MainWindow();
            var factory = new CommandFactory();
            var validator = MatrixValidator.GetInstance;
            var logicProvider = new GameLogic(validator);
            var model = new Game(logicProvider);

            this.engine = new GraphicEngine(graphicUi, UserInputValidator.GetInstance, factory, model, logicProvider);

            graphicUi.Show();
        }
Exemplo n.º 4
0
        public void TestIfResetMethodResetsTheGameFieldCorrectly()
        {
            var gameModel = new Game(new GameLogic(MatrixValidator.GetInstance));
            var fieldBeforeReset = (byte[,])gameModel.Field.Clone();
            gameModel.Reset();

            var differentFieldCount = 0;

            for (int i = 0; i < fieldBeforeReset.GetLength(0); i++)
            {
                for (int j = 0; j < fieldBeforeReset.GetLength(1); j++)
                {
                    if (fieldBeforeReset[i, j] != gameModel.Field[i, j])
                    {
                        differentFieldCount++;
                    }
                }
            }

            Assert.IsTrue(gameModel.Field.Length / differentFieldCount < 2);
        }
Exemplo n.º 5
0
 public void TestIfInitialMovesCountIsZero()
 {
     var gameModel = new Game(new GameLogic(MatrixValidator.GetInstance));
     Assert.AreEqual(0, gameModel.UserMovesCount);
 }
Exemplo n.º 6
0
 public void TestIfGameModelIsCreatedWithInitializedField()
 {
     var gameModel = new Game(new GameLogic(MatrixValidator.GetInstance));
     Assert.IsNotNull(gameModel.Field);
 }