mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using Shouldly;
|
|
using Volo.Abp.AspNetCore.TestBase;
|
|
|
|
namespace DashboardDemo
|
|
{
|
|
public abstract class DashboardDemoWebTestBase : AbpAspNetCoreIntegratedTestBase<DashboardDemoWebTestStartup>
|
|
{
|
|
protected override IHostBuilder CreateHostBuilder()
|
|
{
|
|
return base
|
|
.CreateHostBuilder()
|
|
.UseContentRoot(WebContentDirectoryFinder.CalculateContentRootFolder());
|
|
}
|
|
|
|
protected virtual async Task<T> GetResponseAsObjectAsync<T>(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
|
|
{
|
|
var strResponse = await GetResponseAsStringAsync(url, expectedStatusCode);
|
|
return JsonConvert.DeserializeObject<T>(strResponse, new JsonSerializerSettings
|
|
{
|
|
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
|
});
|
|
}
|
|
|
|
protected virtual async Task<string> GetResponseAsStringAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
|
|
{
|
|
var response = await GetResponseAsync(url, expectedStatusCode);
|
|
return await response.Content.ReadAsStringAsync();
|
|
}
|
|
|
|
protected virtual async Task<HttpResponseMessage> GetResponseAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
|
|
{
|
|
var response = await Client.GetAsync(url);
|
|
response.StatusCode.ShouldBe(expectedStatusCode);
|
|
return response;
|
|
}
|
|
}
|
|
}
|