I have a method with the following signature:
public string ParseFile<T>(string filepath, T model)
As you can see, the model is a generic type. The method is called from the tested code like this:
var model = new
{
SubmittedBy = submittedBy,
SubmittedDateTime = DateTime.Now,
Changes = changes
};
string mailTemplate = provider.ParseFile(filePath, model);
I supply a mock object for the provider. I need to fake the call of this method, to return the value I provide, i.e. I need something like this:
_mockTemplateProvider.Setup(
x => x.ParseFile(It.IsAny<string>(), It.IsAny<object>())).Returns("something");
When the test runs, the value I'm trying to set up is not returned. I can't use It.IsAny(), since the actual type is anonymous. If I try calling the method with an actual instance of object in debugger, it works. But how do I convince it to take an anonymous object? Or just don't care about arguments at all?
"something"as it was setup to do. Try creating an MVCE and see if you still see the problem. It's possible there's something else that's causing the issue here. - Patrick Quirk