I have a test which mocks a non-interface object with a constructor that takes parameters:
[Test]
public void Test()
{
var myObject = Substitute.For<MyObject>("param1", "param2");
_sut.DoSomething(myObject);
myObject.Received().SomeMethodWhichIsCalled();
}
This passes and when I debug the test, I can see SomeMethodWhichIsCalled()
on MyObject
is executed correctly.
However I've now realised this assert does nothing, because I can add the below in:
[Test]
public void Test()
{
var myObject = Substitute.For<MyObject>("param1", "param2");
_sut.DoSomething(myObject);
myObject.DidNotReceive().SomeMethodWhichIsCalled();
myObject.Received().SomeMethodWhichIsCalled();
}
And the test still passes...
Is this a side effect of mocking classes and not interfaces?