77 lines
2.5 KiB
C#
77 lines
2.5 KiB
C#
3 years ago
|
using System;
|
||
2 years ago
|
using System.Data;
|
||
3 years ago
|
using System.IO;
|
||
2 years ago
|
using System.Xml;
|
||
2 years ago
|
using System.Net.Http;
|
||
|
|
||
|
using System.Threading.Tasks;
|
||
|
using Newtonsoft.Json;
|
||
|
using isn.Abstract;
|
||
|
using System.Linq;
|
||
2 years ago
|
using Xunit;
|
||
3 years ago
|
|
||
|
namespace isn.tests
|
||
|
{
|
||
|
public class Tests
|
||
|
{
|
||
2 years ago
|
private DataRow dataRow;
|
||
3 years ago
|
|
||
2 years ago
|
[Fact]
|
||
3 years ago
|
public void HAveADefaultDataProtector()
|
||
3 years ago
|
{
|
||
|
string pass = "a lame and big pass";
|
||
|
isn.IDataProtector _protector = new isn.DefaultDataProtector();
|
||
|
string protectedpass = _protector.Protect(pass);
|
||
|
string unprotectedpass = _protector.UnProtect(protectedpass);
|
||
|
Console.WriteLine(protectedpass);
|
||
2 years ago
|
Assert.Equal(pass, unprotectedpass);
|
||
|
Assert.True(protectedpass!=null);
|
||
|
Assert.True(protectedpass.Length>0);
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
2 years ago
|
[Fact]
|
||
2 years ago
|
public void Test()
|
||
3 years ago
|
{
|
||
2 years ago
|
System.Data.DataTable dataTable = new System.Data.DataTable();
|
||
|
dataTable.Columns.Add(new DataColumn("x"));
|
||
|
dataTable.Columns.Add(new DataColumn("y"));
|
||
|
dataRow = dataTable.NewRow();
|
||
|
dataRow[0]= 1;
|
||
|
dataRow[1]= 2;
|
||
3 years ago
|
|
||
2 years ago
|
dataTable.Rows.Add(dataRow);
|
||
|
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
[Fact]
|
||
2 years ago
|
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);
|
||
|
}
|
||
2 years ago
|
[Fact]
|
||
2 years ago
|
public void TestPush()
|
||
2 years ago
|
{
|
||
|
Program.LoadConfig();
|
||
2 years ago
|
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" });
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
[Fact]
|
||
2 years ago
|
public async Task GetServerResourcesUsingWebRequestAsyncTest()
|
||
|
{
|
||
|
var model = await SourceHelpers.GetServerResourcesUsingWebRequestAsync("Http://localhost:88/index.json");
|
||
|
Console.WriteLine(JsonConvert.SerializeObject(model));
|
||
|
Assert.NotNull(model.Resources);
|
||
2 years ago
|
var pub = model.Resources.FirstOrDefault((r) => r.Type == "PackagePublish/2.0.0");
|
||
|
Assert.True(pub!=null);
|
||
2 years ago
|
}
|
||
|
|
||
3 years ago
|
}
|
||
|
}
|