|
From: John P. <Joh...@de...> - 2005-05-11 17:10:17
|
Hi Thibaut,
This is actually the same problem I ran into that I mentioned in a =
recent list post (the issue is "NMO-44" on the jira.truemesh tracker, =
but doesn't seem to be in the sourceforge tracker). I've got a fix for =
it that seems to work well, but it hasn't been incorporated into the =
official source yet.
If you're interested, I can send you the patch and you can compile your =
own version for the time being.
John.
-----Original Message-----
From: nmo...@li... =
[mailto:nmo...@li...] On Behalf Of Thibaut =
Barr=E8re
Sent: Tuesday, May 10, 2005 11:29 AM
To: <nmo...@li...>
Subject: [Nmock-general] Inherited properties and DynamicMock (known =
bug?)
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
{
MyValue
}
public interface IMyInterface
{
MyEnum Enum { get; }
}
public interface IMyChildInterface : IMyInterface
{
}
[Test]
public void SetupResultWithInheritedProperty()
{
DynamicMock mock =3D new DynamicMock(typeof(IMyChildInterface));
mock.SetupResult("Enum",MyEnum.MyValue);
IMyChildInterface 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.
at NMock.DynamicMock.checkReturnTypeIsValid(String methodName, Object
returnVal, MethodSignature signature)
at NMock.DynamicMock.SetupResult(String methodName, Object returnVal,
Type[] argTypes)
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_ids93&alloc_id=16281&op=3Dick
_______________________________________________
Nmock-general mailing list
Nmo...@li...
https://lists.sourceforge.net/lists/listinfo/nmock-general
|