Using MOQ and a Generic Repository. I'm not able to successfully test the following method.
[TestMethod()]
public void Employee_Service_Get_Users()
{
var mockRep = new Mock<IRepository<Employee>>(MockBehavior.Strict);
IList<Employee> newEmpLst = new List<Employee>();
Employee newEmp = new Employee();
mockRep.Setup(repos => repos.Find() <------ What belongs here?
var service = new EmployeeService(mockRep.Object);
var createResult = service.GetAllActiveEmployees();
Assert.AreEqual(newEmpLst, createResult);
}
It's calling this Method:
public IList<Employee> GetAllActiveEmployees()
{
return _employeeRepository.Find()
.Where(i=>(i.Status =="Active")).ToList(); <----It Bombs Here! ;)
}
My Generic Repository has the following:
public IQueryable<T> Find()
{
var table = this.LookupTableFor(typeof(T));
return table.Cast<T>();
}
I get the following:
Moq.MockException: IRepository`1.Find() invocation failed with
mock behavior Strict. All invocations on the mock must have a corresponding
setup.