Suppose my method-under-test looks like this:
public void TestMe()
DataSet d1 = null;
DataSet d2 = null;
bool process = false;
Helper helper = new Helper();
process = helper.LoadFromDB(out d1, out d2) && d1 != null && d1.Tables != null && d1.Tables.Count > 0
[...run business logic here...]
throw new Exception("Failed to load data from the db");
In order to circumvent using a physical database, I mock "helper.LoadFromDB" in my unit test. The delegate I use in the "DoInstead" method populates the test1DS and test2DS datasets with made-up data, and the "Returns" in my arrange returns true.
Mock.Arrange(() => helper.LoadFromDB(out test1DS, out test2DS))
The problem is that the data sets the mock implementation populates are the ones declared within the unit test, not the ones declared in the method-under-test. So the process flag in the code snippet above still returns false (due to d1 being null), and the business logic I wanted to test (within the "if (process)" block above) never gets run.
Is there a way to map (for lack of a better word) the test1DS and test2DS (that I declared in the unit test code and populated in my DoInstead delegate) to the data sets d1 and d2 declared within the method-under-test, so as to allow the process flag to evaluate to true once the mocked implementation has run?