コード例 #1
0
ファイル: Test1.cs プロジェクト: apavelm/PonyMaze
        public async Task CreateMazeAndGetState()
        {
            var client = new PonyApiClient();

            var mazeId = await client.CreateMaze(20, 20, "Rainbow Dash", 5);

            Assert.AreNotEqual(mazeId, Guid.Empty, "Error: Maze created with Guid.Empty is ID");

            var state = await client.GetMazeCurrentState(mazeId);

            Assert.IsNotNull(state, "Error: state serialization error");
        }
コード例 #2
0
        private async void btnLoadMaze_Click(object sender, EventArgs e)
        {
            txtSequence.Text = "";
            if (!Guid.TryParse(edtMazeId.Text, out _mazeId))
            {
                edtMazeId.Text = "";
                DoLog("Error: Maze ID guid is not valid.");
            }

            // load
            try
            {
                var state = await _client.GetMazeCurrentState(_mazeId);

                _solver = MazeSolver.Load(state);
                DoLog($"Maze with ID = {_mazeId} loaded.");
                DoLog("Maze State: " + state.State);
                DoLog("Maze Result State: " + state.MazeStateResult);
                if (!string.IsNullOrEmpty(state.HiddenImageUrl))
                {
                    DoLog("Hidden Image Url: " + state.HiddenImageUrl);
                }

                await UpdateMazeState(state);
            }
            catch (PonyClientException ex)
            {
                DoLog(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                DoLog("CRITICAL: " + ex.Message);
                return;
            }
        }