I am new to unit test. One thing I am struggling with is to determine what type of test to write for my method. Using the code below as an example, what should I be testing here? what are the various test I can write.
[HttpGet]
[Route("GetPosts")]
public async Task<IActionResult> GetPosts()
{
try
{
var posts = await postRepository.GetPosts();
if (posts == null)
{
return NotFound();
}
return Ok(posts);
}
catch (Exception)
{
return BadRequest();
}
}