【发布时间】:2020-04-18 02:17:36
【问题描述】:
我是单元测试的新手。我正在努力解决的一件事是确定 为我的方法编写什么类型的测试。使用下面的代码作为 例如,我应该在这里测试什么?我能做的各种测试是什么 写。
[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();
}
}
【问题讨论】:
标签: c# unit-testing c#-4.0 xunit