I have the following repository:
interface IReportingRepository where T: Report
{
IEnumerable<T> GetReports<T>(object constraints);
}
and I am trying to mock out a call to this repository as:
var reportingRepostory = new Mock<IReportingRepository>();
reportingRepostory.Setup(x =>
x.GetReports<ServiceReport (Moq.It.IsAny<object>())).
Returns(new List<ServiceReport>(){Report1, Report2});
However instead of passing in
Moq.It.IsAny<object>()
I want to pass the anonymous type
new {Activated = true, Enabled = true}
so that I can setup my expectation that the correct anonymous type is used.
You can use custom matchers with a bit of reflection help:
Where
HasPropertiesmethod is implemented as follows: