コード例 #1
0
        /// <summary>
        /// GET /api/sample 404
        /// </summary>
        private static async Task testGetWithNotFound(AhkResult ahkResult)
        {
            using (var scope = WebAppInit.GetRequestScope())
            {
                var restGetNoResult = await scope.HttpClient.TryGet <homework.Model.SampleData>("/api/sample?input=no", ahkResult, allowNotFound : true);

                if (restGetNoResult.Success)
                {
                    ahkResult.AddPoints(1);
                    ahkResult.Log("GET /api/sample with notfound");
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// DELETE /api/sample
        /// </summary>
        private static async Task testDelete(AhkResult ahkResult)
        {
            using (var scope = WebAppInit.GetRequestScope())
            {
                var deleteOkResponse = await scope.HttpClient.TryDelete($"/api/sample?input=apple", ahkResult);

                if (deleteOkResponse.Success)
                {
                    ahkResult.AddPoints(2);
                    ahkResult.Log("DELETE /api/sample ok");
                }
                else
                {
                    ahkResult.AddProblem("DELETE /api/sample valasz tartalma hibas. DELETE /api/sample yields invalid reponse.");
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// GET /api/sample 200
        /// </summary>
        private static async Task testGetWithSuccess(AhkResult ahkResult)
        {
            using (var scope = WebAppInit.GetRequestScope())
            {
                var restGetResult = await scope.HttpClient.TryGet <homework.Model.SampleData>("/api/sample?input=apple", ahkResult);

                if (restGetResult.Success)
                {
                    if (restGetResult.Value != null && restGetResult.Value.Name.Equals("apple", StringComparison.OrdinalIgnoreCase))
                    {
                        ahkResult.AddPoints(1);
                        ahkResult.Log("GET /api/sample with success");
                    }
                    else
                    {
                        ahkResult.Log("Returned item does not match expected data.");
                    }
                }
            }
        }