Hi,
any reason why the following doesn't work:
[Test]
[Isolated]
public void TestRefArgument()
{
List<int> fakeList = new List<int>() { BELOW_WARNING,
ABOVE_WARNING,
BELOW_WARNING,
BELOW_WARNING,
BELOW_WARNING };
//var fake = new FakedClass();
var fake = Isolate.Fake.Instance<FakedClass>();
Isolate.WhenCalled(() => fake.SomeMethod(out fakeList)).IgnoreCall();
Isolate.Swap.NextInstance<FakedClass>().With(fake);
var target = new UnderTest2();
var actual = target.CheckForCrapWarning("");
Assert.AreEqual(true,actual);
}
class FakedClass
{
public void SomeMethod(out List<int> list)
{
list = null;
}
}
public class UnderTest2
{
private const int _WARNING_THRESHOLD = 30;
//read the file fill the data into the array,
//do some logic over array
public bool CheckForCrapWarning(string fileName)
{
FakedClass parser = new FakedClass();
List<int> listToPass = new List<int>();
parser.SomeMethod(out listToPass);
foreach (var value in listToPass)
{
if (value > _WARNING_THRESHOLD)
return true;
}
return false;
}
}
:!: if you replace the fake creation with a live instance (see the remark), suddenly everything starts working ok.
:oops: also the example in the documentation has several mistakes.