isn/test/isn.tests/PushTest.cs

80 lines
2.5 KiB
C#
Raw Normal View History

2021-08-15 05:31:38 +01:00
using System;
2022-04-09 19:53:26 +01:00
using System.Data;
2021-09-08 01:55:00 +01:00
using System.IO;
2022-04-09 19:53:26 +01:00
using System.Xml;
2022-04-11 01:48:43 +01:00
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using isn.Abstract;
using System.Linq;
2022-04-11 19:57:30 +01:00
using Xunit;
2022-07-03 14:50:57 +01:00
using isn.abst;
2022-07-10 17:05:05 +01:00
using isnd.Entities;
2021-08-15 05:31:38 +01:00
namespace isn.tests
{
public class Tests
{
2022-04-09 19:53:26 +01:00
private DataRow dataRow;
2021-08-15 05:31:38 +01:00
2022-04-11 19:57:30 +01:00
[Fact]
2021-09-08 01:55:00 +01:00
public void HAveADefaultDataProtector()
2021-08-15 05:31:38 +01:00
{
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);
2022-04-11 19:57:30 +01:00
Assert.Equal(pass, unprotectedpass);
Assert.True(protectedpass!=null);
Assert.True(protectedpass.Length>0);
2021-08-15 05:31:38 +01:00
}
2021-09-03 03:07:58 +01:00
2022-04-11 19:57:30 +01:00
[Fact]
2022-04-09 19:53:26 +01:00
public void Test()
2021-09-08 01:55:00 +01:00
{
2022-04-09 19:53:26 +01:00
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;
2021-08-15 05:31:38 +01:00
2022-04-09 19:53:26 +01:00
dataTable.Rows.Add(dataRow);
}
2022-04-11 01:48:43 +01:00
2022-04-11 19:57:30 +01:00
[Fact]
2022-04-11 01:48:43 +01:00
public async Task TestHttpClient()
{
2022-07-10 17:05:05 +01:00
string url = "http://isn.pschneider.fr/" + ApiConfig.Base;
2022-04-11 01:48:43 +01:00
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);
}
2022-04-11 19:57:30 +01:00
[Fact]
2022-04-17 20:36:28 +01:00
public void TestPush()
2022-04-11 01:48:43 +01:00
{
Program.LoadConfig();
2022-07-03 14:50:57 +01:00
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8."
+ Constants.PaquetFileEstension });
2022-04-11 01:48:43 +01:00
}
2022-04-11 19:57:30 +01:00
[Fact]
2022-04-17 17:59:15 +01:00
public async Task GetServerResourcesUsingHttpClientAsyncTest()
2022-04-11 01:48:43 +01:00
{
2022-04-17 20:36:28 +01:00
var model = SourceHelpers.GetServerResources("Http://isn.pschneider.fr/index.json");
2022-04-11 01:48:43 +01:00
Console.WriteLine(JsonConvert.SerializeObject(model));
Assert.NotNull(model.Resources);
2022-04-17 20:36:28 +01:00
var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/"));
2022-04-11 20:36:45 +01:00
Assert.True(pub!=null);
2022-04-11 01:48:43 +01:00
}
2021-08-15 05:31:38 +01:00
}
}