chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi, I'm a new Typemocker ;-)

I have a problem with mocking of properties. When I mock the properties from a "normal" c-sharp class, it works.

When try to mock a property from a interop generated class, i got following error:
"Cannot use Return in this sequence, there must be a mocked statement first
Perhaps you are trying to mock a method from mscorlib."

// CServiceClass is a COM Object
CServiceClass mc = RecorderManager.CreateMockedObject<CServiceClass>();
using (RecordExpectations r = new RecordExpectations())
{
     r.ExpectAndReturn(mc.LoggedIn, 1);
}


plz help
thx
asked by GerhardK (600 points)

2 Answers

0 votes
Hi Gerhard,

Let's take it offline. i've sent an email with request for a reproducing solution. It would be helpful for the investigation.

Thanks,
answered by gilz (14.5k points)
0 votes
Currently Isolator cannot mock ATL proxy because part of it's implementation resides inside MSCorLib.

Instead I suggest Mocking the proxy's interface.
Instead of:

TestServer _tm = RecorderManager.CreateMockedObject<TestServer>();

using(RecordExpectations r = RecorderManager.StartRecording())
{
    r.ExpectAndReturn(_tm.TestCount, 12);
}


Use:
ITestServer _tm = RecorderManager.CreateMockedObject<ITestServer>();

using(RecordExpectations r = RecorderManager.StartRecording())
{
    r.ExpectAndReturn(_tm.TestCount, 12);
}
answered by dhelper (11.9k points)
...