Looking here, I'm led to believe that what I'm trying to do is possible. However, I seem to be getting a failing test, when I believe it should pass.
Here's my test code:
// Arrange
dbOperations = Substitute.For<IDbOperations>();
myClass = new MyClass(dbOperations);
string test = "test string";
// Act
myClass.MyMethod(arg1, arg2, test);
// Assert
dbOperations.Received(2).TestMethod(Arg.Is<MyClass2>(a => a.MyString == test));
I've traced through MyMethod
and it calls dbOperations twice with an instance of MyClass2
where the MyString
property is set to "test string". Have I misread the docs here - is this kind of check even possibly with NSubtitute, and if so, what am I doing wrong?