static void Main(string[] args) { var config = new HttpSelfHostConfiguration("http://localhost:8080"); RouteConfig.RegisterRoutes(config); AutofacWebApi.Setup(config); using (HttpSelfHostServer server = new HttpSelfHostServer(config)) { server.OpenAsync().Wait(); Console.WriteLine("Press Enter to quit."); Console.ReadLine(); } }
public async void API_GetChartsData_Test(string url) { var config = new HttpConfiguration(); RouteConfig.RegisterRoutes(config); AutofacWebApi.Setup(config); var httpServer = new HttpServer(config); var client = HttpClientFactory.Create(innerHandler: httpServer); var response = client.GetAsync(new Uri(url)).Result; //HttpResponseMessage response = await client.GetAsync(new Uri(url)); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var json = JObject.Parse(response.Content.ReadAsStringAsync().Result); var viewModel = json.ToObject <ChartsData>(); Assert.IsType(typeof(ChartsData), viewModel); }