This commit is contained in:
2022-04-11 01:48:43 +01:00
parent cba0720150
commit ee07affbbd
13 changed files with 102 additions and 17 deletions

View File

@ -2,7 +2,13 @@ using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Net.Http;
using NUnit.Framework;
using System.Threading.Tasks;
using Newtonsoft.Json;
using isn.Abstract;
using System.Linq;
namespace isn.tests
{
@ -35,5 +41,35 @@ dataRow[1]= 2;
dataTable.Rows.Add(dataRow);
}
[Test]
public async Task TestHttpClient()
{
string url = "http://localhost:88/index.json";
HttpClient client = new HttpClient();
// var json = await client.GetStringAsync(new System.Uri(url));
var response = await client.GetAsync(url);
var json = await response.Content.ReadAsStringAsync();
var vm = JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
Console.WriteLine( JsonConvert.SerializeObject(vm));
Assert.NotNull(vm);
Assert.NotNull(vm.Resources);
}
[Test]
public async Task TestPush()
{
Program.LoadConfig();
var report = await Program.PushPkgAsync(new string[] { "bin/Debug/isn.1.0.1.nupkg" });
}
[Test]
public async Task GetServerResourcesUsingWebRequestAsyncTest()
{
var model = await SourceHelpers.GetServerResourcesUsingWebRequestAsync("Http://localhost:88/index.json");
Console.WriteLine(JsonConvert.SerializeObject(model));
Assert.NotNull(model.Resources);
Assert.True(model.Resources.Any((r) => r.Type == "PackagePublish/2.0.0"));
}
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
<TargetFrameworks>net45</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
@ -15,6 +15,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\isn\isn.csproj" />
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>