コード例 #1
0
ファイル: Program.cs プロジェクト: surprisable/smarthotel
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
            }
        }