|
From: <thi...@gm...> - 2005-05-11 16:29:33
|
Hi,
I'm getting a NullReferenceException while calling SetupResult for an
inherited property (full testcase below) :
- is it a know issue ?
- which tracker should I use to open an issue for that, if not know already=
?
I found a quick workaround which is to create a custom class
inheriting from DynamicMock, and override Invoke().
regards
Thibaut
Repro:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
public enum MyEnum
{
=09MyValue
}
public interface IMyInterface
{
=09MyEnum Enum { get; }
}
public interface IMyChildInterface : IMyInterface
{
}
[Test]
public void SetupResultWithInheritedProperty()
{
=09DynamicMock mock =3D new DynamicMock(typeof(IMyChildInterface));
=09mock.SetupResult("Enum",MyEnum.MyValue);
=09IMyChildInterface instance =3D (IMyChildInterface)mock.MockInstance;
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
Exception I get :
System.NullReferenceException : Object reference not set to an
instance of an object.
=09at NMock.DynamicMock.checkReturnTypeIsValid(String methodName, Object
returnVal, MethodSignature signature)
=09at NMock.DynamicMock.SetupResult(String methodName, Object returnVal,
Type[] argTypes)
|