Full source code available here.
Unit testing Web API controllers in .NET Core 2 is very easy.
I have very simple GET and POST methods.
1[Route("api/[controller]")] 2public class ValuesController : Controller 3{ 4[HttpGet] 5 public async Task<IActionResult> Get() 6 { 7 // imagine some db logic 8 List<string> values = new List<string>() { "value1", "value2" }; 9 return Ok(values); 10 } 1112[HttpPost] 13 public async Task<IActionResult> Post([FromBody]string value) 14 { 15 // imagine some db logic 16 return Created("", value); 17 } 18} Add an xUnit Test Project to your solution.