I found that Typemock doesn't return consistent result with ReturnRecursiveFakes when comes to List<string> and string, even though both are from mscorlib. It returns null for List, but return empty for string. By right it should either return null for both, or return empty for both.
Here's the code
public class WorldString
{
public List<string> ReturnStringList()
{
throw new NotImplementedException();
}
public string ReturnString()
{
throw new NotImplementedException();
}
}
[TestFixture, Isolated]
public class Class1
{
private WorldString worldString;
[SetUp]
public void Init()
{
worldString = Isolate.Fake.Instance<WorldString>();
}
[Test, ClearMocks]
public void WhenCallTest()
{
var rtrStrg = worldString.ReturnStringList();
Assert.IsNull(rtrStrg); //return null for list
}
[Test, ClearMocks]
public void ReturnStringTest()
{
var rtrStrg = worldString.ReturnString();
Assert.IsEmpty(rtrStrg); //return empty for string
}
}
It seems that the unability to mock return List<string> value is restricted to ReturnRecursiveFakes only-- If I explicitly set a return value for ReturnStringList(), then I can still mock the method. Here's the code that will pass:
[Test, ClearMocks]
public void WhenCallMockTest()
{
Isolate.WhenCalled(() => worldString.ReturnStringList())
.WillReturn(new List<string>());
Assert.AreEqual(0, worldString.ReturnStringList().Count);
}
Is this expected, or a bug?
________
Zx14 Vs Hayabusa