(The code here is C#)
When trying to verify parameters passed to a method on a mocked object:
• Use Setup (which has taken the place of Expect)
• Use It.Is(x => x == ExpectedParameter)
• The lambda expression can be as complex as you like, as long as it returns a Boolean
• !! Important !! Mark it verifiable!
.Setup(x => x.Method(It.Is(y => y == "expected")))
Use callback: This allows you to store the parameter in your own variable and then make assertions on its contents.
string actual = String.Empty;
mock.Setup(x => x.Method(It.IsAny()))
.Callback((param) => actual = param);