'How to verify that a method of a SUT has been called?
let's say I have this class
public class MyClass
{
public void InnerMethod(){}
public void OuterMethod(SomeType sameValue)
{
if(someCondition)
{
InnerMethod();
}
else
{
...
}
}
}
I want to check that the InnerMethod was called
[Fact]
public void CanDoSomething()
{
var sut = new MyClass();
sut.OuterMethod(someValue);
//Assert that InnerMethod was called
}
If InnerMethod belonged to a mocked object, I would have just called mockObject.Verify(x => x.InnerMethod);. However, InnerMethod is a concrete method belonging to the sut itself.
How to check that InnerMethod was called.
Thanks for helping.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
