Exemple #1
0
        public void MapHelperCreateViewModelTest()
        {
            var field = _generationFieldService.GenerateBaseField();
            var vm    = MapHelper.CreateCellViewModel(field);


            Assert.IsNotNull(vm.Children[0][0].Children[0][0].Value);
            Assert.AreEqual(field[1, 1][1, 1].Value, vm.Children[1][1].Children[1][1].Value);
        }
Exemple #2
0
        public void GenerateBaseFieldTest()
        {
            var field = _generationGieldService.GenerateBaseField();

            Assert.IsNotNull(field[0, 0]?[1, 1]?.Value);

            Assert.AreEqual(1, field[0, 0][0, 0].Value);
            Assert.AreEqual(9, field[1, 1][1, 1].Value);
            Assert.AreEqual(8, field[2, 2][2, 2].Value);
        }
Exemple #3
0
        public IActionResult Get([FromQuery] int?defaultIndex = null, [FromQuery] bool generateField = false)
        {
            var result = default(GameViewModel);

            if (generateField)
            {
                var gameField   = _emptyFieldFactory.Create();
                var solvedField = _generationFieldService.GenerateBaseField();

                result = new GameViewModel
                {
                    SolvedField = MapHelper.CreateCellViewModel(solvedField),
                    GameField   = MapHelper.CreateCellViewModel(gameField)
                };
            }
            else
            {
                defaultIndex = defaultIndex.HasValue ? ++defaultIndex : 0;
                if (defaultIndex > _defaultSchemas.Length - 1)
                {
                    defaultIndex = 0;
                }

                result = new GameViewModel
                {
                    SolvedField        = MapHelper.CreateCellViewModel(_defaultSchemas[defaultIndex.Value].SolvedField),
                    GameField          = MapHelper.CreateCellViewModel(_defaultSchemas[defaultIndex.Value].GameField),
                    DefaultSchemaIndex = defaultIndex
                };
            }

            return(Ok(result));
        }
        public void FieldValidationValidTest()
        {
            var field = _generationFieldService.GenerateBaseField();

            Assert.IsTrue(_validateService.Execute(field));
        }