using System; using System.Data; using System.IO; using System.Xml; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; using Isn.Abstract; using System.Linq; using Xunit; using Isn.@abstract; using isnd.Entities; namespace Isn.tests { public class Tests { [Fact] public void HaveADefaultDataProtector() { 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); Assert.Equal(pass, unprotectedpass); Assert.True(protectedpass != null); Assert.True(protectedpass.Length > 0); } [Fact] public async Task TestHttpClient() { string url = "https://isn.pschneider.fr/" + ApiConfig.IndexDotJson; 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(json); Console.WriteLine(JsonConvert.SerializeObject(vm)); Assert.NotNull(vm); Assert.NotNull(vm.Resources); } [Fact] public void TestPush() { Program.LoadConfig(); var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8." + Constants.PaquetFileEstension }); } [Fact] public void GetServerResourcesUsingHttpClientAsyncTest() { var model = SourceHelpers.GetServerResources("Https://isn.pschneider.fr/index.json"); Console.WriteLine(JsonConvert.SerializeObject(model)); Assert.NotNull(model.Resources); var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/")); Assert.True(pub != null); } } }