public async Task GetUsreInfo() { var client = _factory.CreateClient(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var req = new GetMyInfoRequest { UserId = 1 }; var response = await client.PostAsJsonAsync("api/v1/Values/get-my-info", req); // Must be successful. response.EnsureSuccessStatusCode(); // Deserialize and examine results. var stringResponse = await response.Content.ReadAsStringAsync(); //Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); var dataRes = JsonConvert.DeserializeObject <GetMyInfoResponse>(stringResponse); Assert.Equal("ali", dataRes.UserName); }
public async Task <IActionResult> SampleGet(GetMyInfoRequest request) { var result = await _mediator.Send(request); return(Ok(result)); }