I'm trying to use JustMock to test void methods in my class, seeing if underlying conditions are triggered by trying to asserting occurrence on underlying calls. I can't seem to find a good example of this. Here is some quick code to show what I mean.
Example Class:
public class MockingOccurrance
{
public void MyVoidMethod(string myString)
{
switch (myString)
{
case "goodstring":
GoodString(myString);
break;
default:
BadString(myString);
break;
}
}
public void BadString(string badString) => Console.WriteLine($"{badString} is a bad string");
public void GoodString(string goodString) => Console.WriteLine($"{goodString} is a good string");
}
Example Test:
[Test]
public void TestMethod1()
{
var mo = new MockingOccurrance();
mo.MyVoidMethod("a bad string");
Mock.Assert(() => mo.BadString(Arg.AnyString), Occurs.Once());
}
Obviously this doesn't work. Is there any way to make the test detect the call of BadString(string badString) without alot of smelly interfaces?
Thanks!
-Geoff