I am checking that the ModelState.IsValid in my action method that create the Employee
[HttpPost]
public virtual ActionResult Create(EmployeeForm employeeForm)
{
if (this.ModelState.IsValid)
{
try
{
IEmployee employee = this._uiFactoryInstance.Map(employeeForm);
employee.Save();
}
catch (Exception exception)
{
// do anything
}
}
return ...
}
and I wanna mock it in my unit test method using Moq Framework I try to mock it like that
var modelState = new Mock<ModelStateDictionary>();
modelState.Setup(m => m.IsValid).Returns(true);
but it throw an exception in my unit test case any one can help