isn/test/isn.tests/PushTest.cs

65 lines
2.2 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-11 19:57:30 +01:00
[Fact]
2023-01-29 13:04:50 +00: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);
2022-09-23 20:34:51 +01:00
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-11 01:48:43 +01:00
public async Task TestHttpClient()
{
2023-01-29 13:04:50 +00:00
string url = "https://isn.pschneider.fr/" + ApiConfig.IndexDotJson;
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);
2022-09-23 20:34:51 +01:00
Console.WriteLine(JsonConvert.SerializeObject(vm));
2022-04-11 01:48:43 +01:00
Assert.NotNull(vm);
Assert.NotNull(vm.Resources);
}
2022-09-23 20:34:51 +01:00
[Fact]
2022-04-17 20:36:28 +01:00
public void TestPush()
2022-04-11 01:48:43 +01:00
{
2022-09-23 20:34:51 +01:00
Program.LoadConfig();
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8."
2022-07-03 14:50:57 +01:00
+ Constants.PaquetFileEstension });
2022-04-11 01:48:43 +01:00
}
2022-09-23 20:34:51 +01:00
[Fact]
2023-01-29 13:04:50 +00:00
public void GetServerResourcesUsingHttpClientAsyncTest()
2022-04-11 01:48:43 +01:00
{
2023-01-29 13:04:50 +00:00
var model = SourceHelpers.GetServerResources("Https://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-09-23 20:34:51 +01:00
Assert.True(pub != null);
2022-04-11 01:48:43 +01:00
}
2021-08-15 05:31:38 +01:00
}
}