Exemplo n.º 1
0
        public async Task LoadCheck()
        {
            _model.newGame(5);
            Assert.AreEqual(_model.getSize(), 5);

            RoboChaseInfo gameInfo = await _model.loadFromFileAsync(String.Empty);

            _model.newGame(gameInfo.size, gameInfo);

            _mock.Verify(dataAccess => dataAccess.LoadAsync(String.Empty), Times.Once());

            Assert.AreEqual(_model.getRobotPos(), gameInfo.robot);
            Assert.AreEqual(_model.getSize(), 11);
            Assert.AreEqual(gameInfo.size, 11);
            Assert.AreEqual(gameInfo.time, (ulong)0);
            Assert.AreEqual(_model.getTime(), 0);


            for (int i = 0; i < 10; i++)
            {
                int prev = _model.getTime();
                _model.AdvanceTime(this, new System.EventArgs());
                if (_model.isInGame())
                {
                    Assert.IsTrue(prev < _model.getTime());
                }
            }
        }
Exemplo n.º 2
0
        private async void ViewModel_LoadGame(object sender, System.EventArgs e)
        {
            string filePath = string.Empty;

            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "CRAZY files (*.crazy)|*.crazy";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Title            = "Load Robo Chase Files";
                if (openFileDialog.ShowDialog() == true)
                {
                    await _model.loadFromFileAsync(openFileDialog.FileName);

                    filePath = openFileDialog.FileName;

                    _viewModel.LoadEnabled  = "False";
                    _viewModel.SaveEnabled  = "False";
                    _viewModel.PlayEnabled  = "True";
                    _viewModel.PauseEnabled = "False";

                    _viewModel.CurrentGameStatus = "Game has loaded. Press play to continue";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("A fájl betöltése sikertelen!", "Sudoku", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _viewModel.LoadDone();
        }