In a command like
var mockObj = new Mock<MyObject>()
var anotherObj = Utilities.DoStuff();
// some tests...
mockObj.Verify(foo => foo.someMethod(anotherObj));
Does Moq use comparison by identity or by using .Equals() to determine whether someMethod() was ever called with anotherObj as a parameter? In other words, does the object I indicate as a parameter for foo.someMethod() have to be the exact same object that someMethod() was called with earlier for the verification to pass, or does it only have to be one that is equal to anotherObj?
Moqwill compare by identity, it will be looking for the exact instance that you specified using identity. If this is not what you want, and you are looking forequalscomparison instead, you can useIt.Is: