public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var db = scope.ServiceProvider.GetService <SmartHotelWebContext>(); SmartHotelWebContextSeed.Seed(db); } host.Run(); }
public TestServerFixture() { var builder = WebHost.CreateDefaultBuilder() .UseEnvironment("Development") .UseStartup <Startup>(); testServer = new TestServer(builder); using (var scope = testServer.Services.CreateScope()) { var db = scope.ServiceProvider.GetService <SmartHotelWebContext>(); SmartHotelWebContextSeed.Seed(db); } httpClient = testServer.CreateClient(); }
public async Task TestGetAllMemberPhone() { var builder = WebHost.CreateDefaultBuilder() .UseEnvironment("Development") .UseStartup <Startup>(); using (var server = new TestServer(builder)) { using (var scope = server.Services.CreateScope()) { var db = scope.ServiceProvider.GetService <SmartHotelWebContext>(); SmartHotelWebContextSeed.Seed(db); } var httpClient = server.CreateClient(); var response = await httpClient.GetAsync("/api/cities"); response.EnsureSuccessStatusCode(); var jsonStr = await response.Content.ReadAsStringAsync(); var cityList = JsonConvert.DeserializeObject <List <City> >(jsonStr); Assert.NotNull(cityList); } }