I have a method that tests some assumptions and either follows the happy path or ends along the unhappy paths. I either designed it poorly, or I miss the flow control testing method.
if (this.officeInfo.OfficeClosed)
{
this.phoneCall.InformCallerThatOfficeIsClosedAndHangUp();
return;
}
if (!this.operators.GetAllOperators().Any())
{
this.phoneCall.InformCallerThatNoOneIsAvailableAndSendToVoicemail();
return;
}
Call call=null;
forach(var operator in this.operators.GetAllOperators())
{
call = operator.Call();
if(call!=null) {break;}
}
etc. I have introduced my dependencies. I have mokas. I can make sure that this or that is caused, but I don’t know how to check that a "return" is occurring. If TDD means that I am not writing a line until I have a test that fails without it, I am stuck.
How would you test it? Or is there a way to write it, which makes it more verifiable?
: , , , . , . . if, ? , Method_WithParameter_DoesntInvokeMethod8IfMethod7IsTrueandMethod6IsTrueAndMethod5IsTrueAndMethod4IsTrueAndMethod3IsFalseAndMethod2IsTrueAndMethod1isAaaaccck()?