Why doesn't my Moq Test resolve to the appropriate Method.
Calling the Service in my Test:
var service = new EmployeeService(mockScoreRep);
Uses the following Method
public EmployeeService(ICMS_Repository cmsrepository)
{
_cmsRepository = cmsrepository;
}
public EmployeeService(IRepository<Score> scoreRep)
{
_scoreRepository = scoreRep;
}
I get the following Error:
Cannot convert from 'Moq.Mock<IRepository<Score>>' to 'ICMS_Repository'
I suspect the problem is that you want the mock object , not the wrapper:
var service = new EmployeeService(mockScoreRep.Object);
In other words, you want to pass an IRepository<Score>
- not a Moq.Mock<IRepository<Score>>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.