Beispiel #1
0
        public static async Task <int> DeleteTestData(int testId)
        {
            string url = $"http://localhost:3000/api/testdata/{ testId }";

            TestDataModel testdata = new TestDataModel();

            testdata.TestId = testId;
            try
            {
                var response = await ApiTestDataHelper.ApiClient.DeleteAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    return(204);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                logError(ex, testId);
                throw new Exception();
            }
        }
Beispiel #2
0
        public static async Task <TestDataModel> LoadTestData(int testId = 0)
        {
            string url = "";

            if (testId > 0)
            {
                url = $"http://localhost:3000/api/testdata/{ testId }";
            }
            else
            {
                url = $"http://localhost:3000/api/testdata";
            }

            using (HttpResponseMessage response = await ApiTestDataHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    TestDataModel testdata = await response.Content.ReadAsAsync <TestDataModel>();

                    return(testdata);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Beispiel #3
0
        public static async Task <TestDataModel> PostTestData(int testId, double frets, double scale)
        {
            string url = $"http://localhost:3000/api/testdata/";

            TestDataModel testdata = new TestDataModel();

            testdata.TestId      = testId;
            testdata.FretAmount  = frets;
            testdata.ScaleLength = scale;

            StringContent content = new StringContent(JsonConvert.SerializeObject(testdata), Encoding.UTF8, "application/json");

            var response = await ApiTestDataHelper.ApiClient.PostAsync(url, content);

            return(testdata);
        }