This commit is contained in:
31
ApiRoot/ApiRoute.cs
Normal file
31
ApiRoot/ApiRoute.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void ServerApiRootPageShouldFetch()
|
||||
{
|
||||
ApiTextResponse t = await Util.GetNonApiPageAsync("/api/v8/");
|
||||
Util.ValidateHTTPStatusCode(t, 200);
|
||||
t.TextResponse.Should().Contain("<title>AyaNova server</title>");
|
||||
|
||||
}
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
31
Docs/Docs.cs
Normal file
31
Docs/Docs.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void UserManualShouldFetch()
|
||||
{
|
||||
ApiTextResponse t = await Util.GetNonApiPageAsync("docs/");
|
||||
Util.ValidateHTTPStatusCode(t, 200);
|
||||
t.TextResponse.Should().Contain("<title>AyaNova manual</title>");
|
||||
|
||||
}
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
37
util.cs
37
util.cs
@@ -82,6 +82,26 @@ namespace raven_integration
|
||||
return API_BASE_URL + route;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the path to the server root with route appended
|
||||
/// this is used to fetch non-api docs etc
|
||||
/// </summary>
|
||||
/// <param name="route"></param>
|
||||
/// <returns></returns>
|
||||
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<ApiResponse> 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<ApiTextResponse> 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<HttpResponseMessage> DownloadFileAsync(string route, string authToken = null)
|
||||
{
|
||||
|
||||
@@ -507,9 +540,9 @@ namespace raven_integration
|
||||
/// <returns></returns>
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user