uhnit testing from vscode
This commit is contained in:
@ -6,6 +6,8 @@ using isnd.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace isnd.host.tests
|
||||
{
|
||||
public class UnitTestWebHost
|
||||
@ -17,7 +19,7 @@ namespace isnd.host.tests
|
||||
public void TestHaveTestDbContextAndMigrate()
|
||||
{
|
||||
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Assert.Equal("Development", envVar);
|
||||
|
||||
IWebHost webhost = BuildWebHost(new string[] { "--urls", testingUrl });
|
||||
|
||||
using (var serviceScope = webhost.Services.CreateScope())
|
||||
@ -26,16 +28,15 @@ namespace isnd.host.tests
|
||||
|
||||
try
|
||||
{
|
||||
var isnSettings = services.GetRequiredService<IOptions<isn.Settings>>().Value;
|
||||
var myDependency = services.GetRequiredService<ApplicationDbContext>();
|
||||
myDependency.Database.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = services.GetRequiredService<ILogger<Program>>();
|
||||
logger.LogError(ex, "An error occurred.");
|
||||
throw new Exception("Failed " + envVar, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args) =>
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"Nuget": {
|
||||
"Isn": {
|
||||
"ExternalUrl": "http://localhost:5000",
|
||||
"PackagesRootDir" : "packages",
|
||||
"ProtectionTitle": "protected-data-v1",
|
||||
"MaxUserKeyCount": 5
|
||||
},
|
||||
"Smtp": {
|
Reference in New Issue
Block a user