I use Moq all the time for unit tests. Sometimes though I am mocking methods that have a lot of parameters.
Imagine a method like this:
public class WorkClient {
public void DoSomething(string itemName,
int itemCount,
ServiceClientCredential cred,
CancellationToken = default(CancellationToken){}
}
When I go to setup a mock, I end up having to do quite a lot of It.IsAny<T>(). I normally make one mocked instance per each test so I don't care about matching params.
But my mocks still look like this
var newMockClient = new Mock<WorkClient>();
newMockClient.Setup(x => x.DoSomething(
It.IsAny<string>(),
It.IsAny<int>(),
It.IsAny<ServiceClientCredential(),
It.IsAny<CancellationToken>())
.Returns(blah);
I would love to be able to just lazily instead use a LazySetup if it exists, like this.
newMockClient.Setup(x=>x.DoSomething()).Returns(blah);
Is there any lazy mode like this?