uhnit testing from vscode
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ packages/
|
|||||||
bower_components/
|
bower_components/
|
||||||
test/isn.tests/bin
|
test/isn.tests/bin
|
||||||
test/isn.tests/obj/
|
test/isn.tests/obj/
|
||||||
|
test/isnd.tests/appsettings.Testing.json
|
||||||
|
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -4,5 +4,9 @@
|
|||||||
"dotnet-test-explorer.showCodeLens": true,
|
"dotnet-test-explorer.showCodeLens": true,
|
||||||
"dotnet-test-explorer.testArguments": "",
|
"dotnet-test-explorer.testArguments": "",
|
||||||
"nxunitExplorer.nunit": "${workspaceFolder}/packages/nunit3-console.1.0.0/lib/net20/nunit3-console.exe",
|
"nxunitExplorer.nunit": "${workspaceFolder}/packages/nunit3-console.1.0.0/lib/net20/nunit3-console.exe",
|
||||||
"nxunitExplorer.xunit": "${workspaceFolder}/packages/xunit.runner.console.2.4.1/tools/net472/xunit.console.exe"
|
"nxunitExplorer.xunit": "${workspaceFolder}/packages/xunit.runner.console.2.4.1/tools/net472/xunit.console.exe",
|
||||||
|
"nxunitExplorer.modules": [
|
||||||
|
"test/**/bin/**/*.{dll,exe}"
|
||||||
|
],
|
||||||
|
"nxunitExplorer.logpanel": true
|
||||||
}
|
}
|
9
.vscode/tasks.json
vendored
9
.vscode/tasks.json
vendored
@ -66,15 +66,6 @@
|
|||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": "launch-dotnet",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"${workspaceFolder}/bin/Debug/netcoreapp2.1/isnd.dll"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "watch",
|
"label": "watch",
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
# compiler tout
|
# compiler tout
|
||||||
dotnet publish -c Release
|
dotnet publish -c Release
|
||||||
# MAJ du serveur
|
# MAJ du serveur
|
||||||
|
@ -24,7 +24,7 @@ namespace isnd.Controllers
|
|||||||
const int maxTake = 100;
|
const int maxTake = 100;
|
||||||
|
|
||||||
const string defaultSemVer = "2.0.0";
|
const string defaultSemVer = "2.0.0";
|
||||||
private readonly Resource[] _ressources;
|
private readonly Resource[] _resources;
|
||||||
private readonly ILogger<PackagesController> _logger;
|
private readonly ILogger<PackagesController> _logger;
|
||||||
private readonly IDataProtector _protector;
|
private readonly IDataProtector _protector;
|
||||||
|
|
||||||
@ -48,13 +48,13 @@ namespace isnd.Controllers
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_packageManager = pm;
|
_packageManager = pm;
|
||||||
_unleashĈlient = unleashĈlient;
|
_unleashĈlient = unleashĈlient;
|
||||||
_ressources = _packageManager.GetResources(_unleashĈlient).ToArray();
|
_resources = _packageManager.GetResources(_unleashĈlient).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
|
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
|
||||||
public IActionResult ApiIndex()
|
public IActionResult ApiIndex()
|
||||||
{
|
{
|
||||||
return Ok(_ressources);
|
return Ok(new { version = "3.0.0", resources = _resources });
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /autocomplete?id=isn.protocol&prerelease=true
|
// GET /autocomplete?id=isn.protocol&prerelease=true
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
public class Resource
|
public class Resource
|
||||||
{
|
{
|
||||||
public string id {get; set; }
|
[JsonProperty("@id")]
|
||||||
public string type {get; set; }
|
public string Id {get; set; }
|
||||||
public string comment {get; set; }
|
|
||||||
|
[JsonProperty("@type")]
|
||||||
|
public string Type {get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("comment")]
|
||||||
|
public string Comment {get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,43 +40,43 @@ namespace isnd.Services
|
|||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
id = extUrl + ApiConfig.Publish,
|
Id = extUrl + ApiConfig.Publish,
|
||||||
type = "PackagePublish/2.0.0",
|
Type = "PackagePublish/2.0.0",
|
||||||
comment = "Package Publish service"
|
Comment = "Package Publish service"
|
||||||
});
|
});
|
||||||
// under dev, only leash in release mode
|
// under dev, only leash in release mode
|
||||||
if (unleashClient.IsEnabled("pkg-get", false))
|
if (unleashClient.IsEnabled("pkg-get", false))
|
||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
id = extUrl + ApiConfig.Base,
|
Id = extUrl + ApiConfig.Base,
|
||||||
type = "PackageBaseAddress/3.0.0",
|
Type = "PackageBaseAddress/3.0.0",
|
||||||
comment = "Package Base Address service"
|
Comment = "Package Base Address service"
|
||||||
});
|
});
|
||||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
id = extUrl + ApiConfig.AutoComplete,
|
Id = extUrl + ApiConfig.AutoComplete,
|
||||||
type = "SearchAutocompleteService/3.5.0",
|
Type = "SearchAutocompleteService/3.5.0",
|
||||||
comment = "Auto complete service"
|
Comment = "Auto complete service"
|
||||||
});
|
});
|
||||||
if (unleashClient.IsEnabled("pkg-search", false))
|
if (unleashClient.IsEnabled("pkg-search", false))
|
||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
id = extUrl + ApiConfig.Search,
|
Id = extUrl + ApiConfig.Search,
|
||||||
type = "SearchQueryService/3.5.0",
|
Type = "SearchQueryService/3.5.0",
|
||||||
comment = "Search Query service"
|
Comment = "Search Query service"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (unleashClient.IsEnabled("pkg-catalog", false))
|
if (unleashClient.IsEnabled("pkg-catalog", false))
|
||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
id = extUrl + ApiConfig.Catalog,
|
Id = extUrl + ApiConfig.Catalog,
|
||||||
type = "Catalog/3.0.0",
|
Type = "Catalog/3.0.0",
|
||||||
comment = "Package Catalog Index"
|
Comment = "Package Catalog Index"
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace isn.tests
|
namespace isn.tests
|
||||||
@ -20,20 +22,7 @@ namespace isn.tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test1()
|
public void HAveADefaultDataProtector()
|
||||||
{
|
|
||||||
string pass = "a";
|
|
||||||
isn.IDataProtector _protector = new isn.DefaultDataProtector();
|
|
||||||
string protectedpass = _protector.Protect(pass);
|
|
||||||
string unprotectedpass = _protector.UnProtect(protectedpass);
|
|
||||||
Console.WriteLine(protectedpass);
|
|
||||||
Assert.AreEqual(pass, unprotectedpass);
|
|
||||||
Assert.Pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Test26()
|
|
||||||
{
|
{
|
||||||
string pass = "a lame and big pass";
|
string pass = "a lame and big pass";
|
||||||
isn.IDataProtector _protector = new isn.DefaultDataProtector();
|
isn.IDataProtector _protector = new isn.DefaultDataProtector();
|
||||||
@ -41,8 +30,10 @@ namespace isn.tests
|
|||||||
string unprotectedpass = _protector.UnProtect(protectedpass);
|
string unprotectedpass = _protector.UnProtect(protectedpass);
|
||||||
Console.WriteLine(protectedpass);
|
Console.WriteLine(protectedpass);
|
||||||
Assert.AreEqual(pass, unprotectedpass);
|
Assert.AreEqual(pass, unprotectedpass);
|
||||||
Assert.Pass();
|
Assert.Pass($"Good jod man! (decoding {protectedpass})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not a [Test]
|
||||||
public void TestParseCplus()
|
public void TestParseCplus()
|
||||||
{
|
{
|
||||||
INeedEngine engine = new Engine();
|
INeedEngine engine = new Engine();
|
||||||
@ -50,12 +41,14 @@ namespace isn.tests
|
|||||||
Assert.Equals((INeedEngine)engine.Parse("c+"), c.Add(Ring.One));
|
Assert.Equals((INeedEngine)engine.Parse("c+"), c.Add(Ring.One));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AssertIRingIsABody()
|
public void AssertIRingIsABody()
|
||||||
{
|
{
|
||||||
Ring c = new Ring();
|
Ring c = new Ring();
|
||||||
Ring one = Ring.One;
|
Ring one = Ring.One;
|
||||||
Assert.True(c.Mult(one).Equals(c));
|
Assert.True(c.Mult(one).Equals(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssertIRingIsARing()
|
public void AssertIRingIsARing()
|
||||||
{
|
{
|
||||||
AssertIRingIsABody();
|
AssertIRingIsABody();
|
||||||
@ -64,5 +57,18 @@ namespace isn.tests
|
|||||||
Assert.True(c.Add(zero).Equals(c));
|
Assert.True(c.Add(zero).Equals(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AssertReadInput()
|
||||||
|
{
|
||||||
|
var oldOut = Console.Out;
|
||||||
|
StringBuilder censoredTxt = new StringBuilder();
|
||||||
|
var newOut = new StringWriter(censoredTxt);
|
||||||
|
Console.SetOut(newOut);
|
||||||
|
Console.WriteLine("~~censored~~");
|
||||||
|
Console.SetOut(oldOut);
|
||||||
|
Console.Write("Hello ");
|
||||||
|
Console.Write(censoredTxt);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,8 @@ using isnd.Data;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace isnd.host.tests
|
namespace isnd.host.tests
|
||||||
{
|
{
|
||||||
public class UnitTestWebHost
|
public class UnitTestWebHost
|
||||||
@ -17,7 +19,7 @@ namespace isnd.host.tests
|
|||||||
public void TestHaveTestDbContextAndMigrate()
|
public void TestHaveTestDbContextAndMigrate()
|
||||||
{
|
{
|
||||||
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||||
Assert.Equal("Development", envVar);
|
|
||||||
IWebHost webhost = BuildWebHost(new string[] { "--urls", testingUrl });
|
IWebHost webhost = BuildWebHost(new string[] { "--urls", testingUrl });
|
||||||
|
|
||||||
using (var serviceScope = webhost.Services.CreateScope())
|
using (var serviceScope = webhost.Services.CreateScope())
|
||||||
@ -26,16 +28,15 @@ namespace isnd.host.tests
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var isnSettings = services.GetRequiredService<IOptions<isn.Settings>>().Value;
|
||||||
var myDependency = services.GetRequiredService<ApplicationDbContext>();
|
var myDependency = services.GetRequiredService<ApplicationDbContext>();
|
||||||
myDependency.Database.Migrate();
|
myDependency.Database.Migrate();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = services.GetRequiredService<ILogger<Program>>();
|
throw new Exception("Failed " + envVar, ex);
|
||||||
logger.LogError(ex, "An error occurred.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWebHost BuildWebHost(string[] args) =>
|
public static IWebHost BuildWebHost(string[] args) =>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Nuget": {
|
"Isn": {
|
||||||
|
"ExternalUrl": "http://localhost:5000",
|
||||||
"PackagesRootDir" : "packages",
|
"PackagesRootDir" : "packages",
|
||||||
|
"ProtectionTitle": "protected-data-v1",
|
||||||
"MaxUserKeyCount": 5
|
"MaxUserKeyCount": 5
|
||||||
},
|
},
|
||||||
"Smtp": {
|
"Smtp": {
|
Reference in New Issue
Block a user