I am trying to verify a parameter that is a class. The code being tested is fine. The bug is in the test.
I have tried two methods, both of which have failed.
Here are my attempts:
1:
this.MockImageResizeFilter.Verify(m => m.Filter(this.UploadedFileData, new ImageFilterOptions()
{
Width = 256,
Height = 256,
}));
This always fails, even though an object passed as the second parameter has equal properties. The first parameter is verified fine.
2:
this.MockImageResizeFilter.Setup(m => m.Filter(It.IsAny<byte[]>(), It.IsAny<ImageFilterOptions>()))
.Callback<byte[], ImageFilterOptions>((data, options) =>
{
Assert.AreEqual(this.UploadedFileData, data, "data");
Assert.AreEqual(filterOptions.Width, options.Width, "Width");
Assert.AreEqual(filterOptions.Height, options.Height, "Height");
}
);
This always passes, even when it should fail. The Asserts in the callback do fail, but the exception is not passed to the outer context, and thus the test always passes.
Can you help me find what I am doing wrong?