|
|
|
@ -10,6 +10,9 @@ using Microsoft.Extensions.Options;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting.Server;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace isnd.host.tests
|
|
|
|
|
{
|
|
|
|
@ -19,7 +22,7 @@ namespace isnd.host.tests
|
|
|
|
|
public void TestHaveTestDbContextAndMigrate()
|
|
|
|
|
{
|
|
|
|
|
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IWebHost webhost = BuildWebHost(new string[0]);
|
|
|
|
|
|
|
|
|
|
using (var serviceScope = webhost.Services.CreateScope())
|
|
|
|
@ -38,25 +41,35 @@ namespace isnd.host.tests
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
|
|
|
|
WebHost.CreateDefaultBuilder(args)
|
|
|
|
|
.UseStartup<Startup>()
|
|
|
|
|
.Build();
|
|
|
|
|
.UseStartup<Startup>().Build();
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
|
|
public async Task NugetInstallsTest()
|
|
|
|
|
{
|
|
|
|
|
IWebHost webhost = BuildWebHost(new string[0]);
|
|
|
|
|
Task running = Task.Run(async () => await webhost.StartAsync());
|
|
|
|
|
ProcessStartInfo psi = new ProcessStartInfo("nuget");
|
|
|
|
|
psi.ArgumentList.Add("install");
|
|
|
|
|
psi.ArgumentList.Add("isn");
|
|
|
|
|
psi.ArgumentList.Add("gitversion");
|
|
|
|
|
psi.ArgumentList.Add("-PreRelease");
|
|
|
|
|
psi.ArgumentList.Add("-Source");
|
|
|
|
|
psi.ArgumentList.Add("http://localhost:5000");
|
|
|
|
|
Process p = Process.Start(psi);
|
|
|
|
|
p.WaitForExit();
|
|
|
|
|
await webhost.StopAsync();
|
|
|
|
|
Assert.True(p.ExitCode == 0, "nuget install failed!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PrintAddresses(IServiceProvider services)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Checking addresses...");
|
|
|
|
|
var server = services.GetRequiredService<IServer>();
|
|
|
|
|
var addressFeature = server.Features.Get<IServerAddressesFeature>();
|
|
|
|
|
foreach (var address in addressFeature.Addresses)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Listing on address: " + address);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|