This is for a method where the blocking part is at the outside (top or bottom) of the method
- Call the Method
Example:
Method(param1)
- Select everything that isn't the problem
- Extract into public method called
Method2
- Call
Method2
instead Example:Method2(newParams)
This is for method where the blocking part is in the middle of the method
- Call the Method passing null for all params
Example:
Method(param1)
- See the failing error:
Example: Error when callingobject.Method(param1,param2);
- Pass in a mock for the
object
where the call is failing - See the new failing error:
Example: Unexpected call toobject.Method(param1,param2);
- add Mock behavior for that call
- repeat
var listMock = new Mock<IList>(MockBehavior.Strict);
listMock.Setup(l => l.Count).Returns(5).AtMost(1);
IList list = listMock.Object;
Assert.AreEqual(5, list.Count);
- Call Method
- See Problem
- Solve Problem
- If at Top or Bottom
- Peel
- If in Middle
- Slice
- If at Top or Bottom
- Repeat until done