Hi all,
I have a problem mocking static methods. I use the newest Isolator (6.0.7.0).
The final line in the following code fails with a null reference exception:
[Isolated]
[TestMethod]
public void Test()
{
XmlDictionaryWriter writer = Isolate.Fake.Instance<XmlDictionaryWriter>();
Isolate.Fake.StaticMethods<XmlDictionaryWriter>(Members.CallOriginal);
Stream s = Isolate.Fake.Instance<Stream>();
Isolate.WhenCalled(() => XmlDictionaryWriter.CreateTextWriter(s)).WillReturn(writer);
}
Exception:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=TypeMock
StackTrace:
at gq.a()
at ee.a()
at h9.a(Type A_0, Object A_1, MethodBase A_2, String A_3, TypeParams A_4)
at h9.a(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType, Object p1)
at System.Xml.XmlDictionaryWriter.CreateTextWriter(Stream stream)
at XXX.FinancialWebservices.Receiver.UnitTest.Chunk.ChunkedMessageReaderTest.<>c__DisplayClass6.<Test>b__5() in
InnerException:
XmlDictionaryReader is from the System.Runtime.Serialization assembly.