public void FlagSetted_MinesLeftDown()
        {
            var vm = new MinefieldViewModelTest();

            vm.Field.Cells[0][0].SetFlag();

            Assert.AreEqual(MinefieldViewModelTest.DefaultMineCount - 1, vm.MinesLeft);
        }
        public void MinefieldResize_HeightInContainer(int fieldHeight, int fieldWidth, double heightRatio, double widthRatio)
        {
            MinefieldViewModelTest vm = new MinefieldViewModelTest(fieldHeight, fieldWidth);
            double height             = cellSizePx * heightRatio;
            double width = cellSizePx * widthRatio;

            vm.SetSize(width, height);

            Assert.LessOrEqual(vm.FieldHeightPx, height);
        }
        public void OneOfSideAllwaysHasMaximum(int fieldHeight, int fieldWidth, double heightRatio, double widthRatio)
        {
            MinefieldViewModelTest vm = new MinefieldViewModelTest(fieldHeight, fieldWidth);

            double height = cellSizePx * heightRatio;
            double width  = cellSizePx * widthRatio;

            vm.SetSize(width, height);

            bool widthIsMax  = width == vm.FieldWidthPx;
            bool heightIsMax = height == vm.FieldHeightPx;

            Assert.IsTrue(widthIsMax || heightIsMax);
        }
        public void OpenAllMines_MinenLeftToZero()
        {
            var vm    = new MinefieldViewModelTest();
            var cells = vm.Field.Cells;

            for (int i = 0; i < MinefieldViewModelTest.DefaultFieldWidthCell; ++i)
            {
                for (int j = 0; j < MinefieldViewModelTest.DefaultFieldHeightCell; ++j)
                {
                    var cell = cells[j][i];
                    if (cell.Mined)
                    {
                        cell.SetFlag();
                    }
                }
            }

            Assert.AreEqual(0, vm.MinesLeft);
        }
        public void CellProportionsMustBeNearSquare(int fieldHeight, int fieldWidth, double heightRatio, double widthRatio)
        {
            // Клетки должны быть примерно квадратными не зависимо от соотношения сторон поля.
            // Допустимо отклонение в 1-2 пикселя.
            //Так же нужно не забыть выполнить рефакторинг MinefieldViewModel:ResizeField

            MinefieldViewModelTest vm = new MinefieldViewModelTest(fieldHeight, fieldWidth);
            double height             = cellSizePx * heightRatio;
            double width = cellSizePx * widthRatio;

            vm.SetSize(width, height);

            double cellHeight = vm.FieldHeightPx / fieldHeight;
            double cellWidth  = vm.FieldWidthPx / fieldWidth;

            double allowableError = 2;

            Assert.LessOrEqual(Math.Abs(cellHeight - cellWidth), allowableError);
        }
        public void GameStart_AllMinesLeft()
        {
            var vm = new MinefieldViewModelTest();

            Assert.AreEqual(MinefieldViewModelTest.DefaultMineCount, vm.MinesLeft);
        }