public async Task Test1() { var factory = new TestWebApplicationFactory <Startup>(); var client = factory.CreateClient(); var respone = await client.GetAsync("api/values"); Assert.Equal(HttpStatusCode.OK, respone.StatusCode); }
public async Task Test2() { var factory = new TestWebApplicationFactory <Startup>(); var client = factory.CreateClient(); var req = new SendMessageRequest { Message = "a message" }; var dd = JsonConvert.SerializeObject(req); var input = new StringContent(dd, Encoding.UTF8, "application/json"); var respone = await client.PostAsync("api/values", input); Assert.Equal(HttpStatusCode.OK, respone.StatusCode); }