views:

34

answers:

0

I've the following method defined

public interface IData
{
    T GetUserById<T>(int id) where T : IMyUser, new();
}

The actual use of this method is like :

da.GetUserById<MyUser>(id);

where the MyUser is an internal class defined in the business logic and cannot be used by the unittest.

In NMock this can be done using this code:

Expect.Once.On(dataMock).Method("GetUserById").With(FakeUser);

Example can be found here.

How to do the same with Moq ?

The Moq code should be something like this:

var data = new Mock<IData>();
data.Setup(d => d.GetUserById<MyUser ???>(1)).Returns(???);

Note : this question is related to this one.