KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm checking ModelState.IsValid in my controller action method that creates an Employee like this: [HttpPost] public virtual ActionResult Create(EmployeeForm employeeForm) { if (this.ModelState.IsValid) { IEmployee employee = this._uiFactoryInstance.Map(employeeForm); employee.Save(); } // Etc. } I want to mock it in my unit test method using Moq Framework. I tried to mock it like this: var modelState = new Mock<ModelStateDictionary>(); modelState.Setup(m => m.IsValid).Returns(true); But this throws an exception in my unit test case. Can anyone help me out here?
Tags (comma-separated)
Save Edits
Cancel