I am new to UnitTesting and just ran into a situation, I don’t know how to handle, and I would appreciate any tips :)
The situation is this, imagine two methods:
public bool HelperMethod(string substr) {
return substr.Equals("abc");
}
public bool ActualMethod(string str) {
for (var i=0; i<str.Length; i++) {
var substr = str.Substring(i, 3);
if (HelperMethod(substr))
return true;
}
return false;
}
HelperMethod functions without dependencies, ActualMethod depends on HelperMethod, so its UnitTest will fail if HelperMethod is one.
In fact, if I'm not mistaken, this is where a mockery of drugs should come to the rescue.
( ) ( , ActualMethod ). HelperMethod ActualMethod, HelperMethod , ( , HelperMethod ..).
: , ? ? (, Assert (HelperMethodPassed)? ?
, HelperMethod ActualMethod , .
, !:)
PS:
, , #, MSTest ( , ).
: HelperMethod ActualMethod .