Using Moq with overloaded method

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'
Jon Skeet
people
quotationmark

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>>.

people

See more on this question at Stackoverflow