How to unit test the below catch block?
Below is my controller definition:
public class RunController : Controller
{
Public ActionResult GetExtraRun()
{
try{
return View("ExtraRun");
} catch(Exception ex)
{
_log.Error("Index -" + ex.Message, ex);
TempData[ErrorInfo] = GetErrorInfo(ex, "RunStatus");
return RedirectToAction("Index", "RunErrorHandling");
}
}
}
I am using NUnit and Moq latest with Asp.NET Core MVC 3.0 version.
So I will have two test case as below
- ) To check it is return View successfully.
- ) I need to check catch block as a part of code coverage.
So I need help in 2nd point in the above given code.