#34 Unable to access a property on an inherited object

open
nobody
nmock2 (11)
5
2009-04-02
2009-04-02
Chris Altman
No

am getting this error when trying to set an expectation on an object I mocked that inherits from MembershipUser:

ContactRepositoryTests.UpdateTest : FailedSystem.InvalidProgramException: JIT Compiler encountered an internal limitation.

Server stack trace:
at MockObjectType1.ToString()

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref MessageData msgData, Int32 type)
at System.Object.ToString()
at NMock2.Internal.ExpectationBuilder.On(Object receiver)

Here are the tools I am using...

VS2008 (SP1)
Framework 3.5
nUnit 2.4.8
nMock 2.0.0.44
Resharper 4.1

I am at a loss as to why this would be happening. Any help would be appreciated.

There error occurs on the Expect.Once line...

[TestFixture]
public class ContactRepositoryTests
{
private Mockery m_Mockery;
private IUser m_MockUser;

[SetUp]
public void Setup()
{
m_Mockery = new Mockery();
m_MockUser = m_Mockery.NewMock<IUser>();
}

[TearDown]
public void TearDown()
{
m_Mockery.Dispose();
}

[Test]
public void UpdateTest()
{
string modifiedById = Guid.NewGuid().ToString();

Expect.Once
.On(m_MockUser)
.GetProperty("ProviderUserKey")
.Will(Return.Value(modifiedById));
}
}
}

Discussion