Exemple #1
0
        public async Task CreateMazeWithError()
        {
            var client = new PonyApiClient();

            // Wrong size: width
            await Assert.ThrowsExceptionAsync <PonyClientException>(async() =>
            {
                await client.CreateMaze(10, 20, "Rainbow Dash", 5);
            });

            // Wrong size: height
            await Assert.ThrowsExceptionAsync <PonyClientException>(async() =>
            {
                await client.CreateMaze(20, 10, "Rainbow Dash", 5);
            });

            // Wrong name
            await Assert.ThrowsExceptionAsync <PonyClientException>(async() =>
            {
                await client.CreateMaze(20, 20, "blabla", 5);
            });

            // Wrong difficulty
            await Assert.ThrowsExceptionAsync <PonyClientException>(async() =>
            {
                await client.CreateMaze(20, 20, "Rainbow Dash", 100);
            });
        }
Exemple #2
0
        private async void btnCreateMaze_Click(object sender, EventArgs e)
        {
            var w    = (int)edtMazeWidth.Value;
            var h    = (int)edtMazeHeight.Value;
            var d    = (int)edtDifficulty.Value;
            var name = edtPlayerName.Text;

            try
            {
                _mazeId = await _client.CreateMaze(w, h, name, d);
            }
            catch (PonyClientException ex)
            {
                DoLog(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                DoLog("CRITICAL: " + ex.Message);
                return;
            }

            edtMazeId.Text   = _mazeId.ToString();
            txtSequence.Text = "";
            DoLog("Maze created, id = " + _mazeId);
            DoLog($"Size: {w}x{h}, Difficulty: {d}");

            await UpdateMazeState();
        }
Exemple #3
0
        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");
        }