using System; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore; using Xunit; using isnd.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Collections.Generic; namespace isnd.host.tests { public class UnitTestWebHost { [Fact] public void TestHaveTestDbContextAndMigrate() { string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); IWebHost webhost = BuildWebHost(new string[0]); using (var serviceScope = webhost.Services.CreateScope()) { var services = serviceScope.ServiceProvider; try { var isnSettings = services.GetRequiredService>().Value; var myDependency = services.GetRequiredService(); myDependency.Database.Migrate(); } catch (Exception ex) { throw new Exception("Failed " + envVar, ex); } } } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); private class Butts: List { public bool Im12 { get; set; } } private class Butt { public bool Im12 { get; set; } } } }