From f5be2e296b91c0515188519f44a99e3f5b09a6a1 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 23 Oct 2019 22:13:24 +0000 Subject: [PATCH] --- ApiRoot/ApiRoute.cs | 31 +++++++++++++++++++++++++++++++ Docs/Docs.cs | 31 +++++++++++++++++++++++++++++++ util.cs | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 ApiRoot/ApiRoute.cs create mode 100644 Docs/Docs.cs diff --git a/ApiRoot/ApiRoute.cs b/ApiRoot/ApiRoute.cs new file mode 100644 index 0000000..aa10b65 --- /dev/null +++ b/ApiRoot/ApiRoute.cs @@ -0,0 +1,31 @@ +using System; +using Xunit; +using Newtonsoft.Json.Linq; +using FluentAssertions; +using System.Collections.Generic; +using System.Collections.Concurrent; + +namespace raven_integration +{ + + public class ApiRoute + { + + + + /// + /// + /// + [Fact] + public async void ServerApiRootPageShouldFetch() + { + ApiTextResponse t = await Util.GetNonApiPageAsync("/api/v8/"); + Util.ValidateHTTPStatusCode(t, 200); + t.TextResponse.Should().Contain("AyaNova server"); + + } + + //================================================== + + }//eoc +}//eons diff --git a/Docs/Docs.cs b/Docs/Docs.cs new file mode 100644 index 0000000..4d47e96 --- /dev/null +++ b/Docs/Docs.cs @@ -0,0 +1,31 @@ +using System; +using Xunit; +using Newtonsoft.Json.Linq; +using FluentAssertions; +using System.Collections.Generic; +using System.Collections.Concurrent; + +namespace raven_integration +{ + + public class Docs + { + + + + /// + /// + /// + [Fact] + public async void UserManualShouldFetch() + { + ApiTextResponse t = await Util.GetNonApiPageAsync("docs/"); + Util.ValidateHTTPStatusCode(t, 200); + t.TextResponse.Should().Contain("AyaNova manual"); + + } + + //================================================== + + }//eoc +}//eons diff --git a/util.cs b/util.cs index bf4816c..617f740 100644 --- a/util.cs +++ b/util.cs @@ -82,6 +82,26 @@ namespace raven_integration return API_BASE_URL + route; } + /// + /// Get the path to the server root with route appended + /// this is used to fetch non-api docs etc + /// + /// + /// + public static string CleanNonApiRoute(string route) + { + // public static string API_BASE_URL = "http://localhost:7575/api/v8/"; + //public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/"; + + + if (!route.StartsWith('/')) + { + route = "/" + route; + } + + return API_BASE_URL.Split("/api/")[0] + route; + } + public async static Task GetAsync(string route, string authToken = null, string bodyJsonData = null) { init(); @@ -117,6 +137,19 @@ namespace raven_integration return new ApiTextResponse() { HttpResponse = response, TextResponse = responseAsString }; } + + public async static Task GetNonApiPageAsync(string route) + { + init(); + var requestMessage = new HttpRequestMessage(HttpMethod.Get, CleanNonApiRoute(route)); + HttpResponseMessage response = await client.SendAsync(requestMessage); + var responseAsString = await response.Content.ReadAsStringAsync(); + return new ApiTextResponse() { HttpResponse = response, TextResponse = responseAsString }; + } + + + + public static async Task DownloadFileAsync(string route, string authToken = null) { @@ -507,9 +540,9 @@ namespace raven_integration /// public static string UserRequiredCustomFieldsJsonString() { - //Note c1 is only required custom, c2 is defined but is not required so skipping it here + //Note c1 is only required custom, c2 is defined but is not required so skipping it here dynamic dCustomField = new JObject(); - dCustomField.c1 = "UnitTestUtilSampleText"; + dCustomField.c1 = "UnitTestUtilSampleText"; return dCustomField.ToString(); }