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
I've recordings block:

[TestMethod]
public void Foo()
{
using (RecordExpectations recorder = new RecordExpectations())
{
BVDBSLib.IPtBvRoot _root = new BVDBSLib.PtBvRoot();
recorder.RepeatAlways();
}
}

Where BVDBSLib.PtBvRoot is class I've got after adding a reference to the COM object. COM object is implemented in the NT service. After starting test I see the service is starting. So, looks like in the recordings block test creates real remote COM object.

Is it bug or I'm doing something wrong?
asked by tom3m (9.7k points)

3 Answers

0 votes
Hi,
It seems that not all calls to BVDBSLib.PtBvRoot are being mocked and somewhere along the line the service is being initialized.
Its hard by this snippet to see exactly what goes on there, so my best advice for you is to use the Tracer tool and see if any unmocked calls on BVDBSLib.PtBvRoot are made during the tests run.
Specifically I would keep an eye on the various ctors & cctor.

If you are able to post the entire test code that might help also.
answered by lior (13.2k points)
0 votes
Thats entire test!
Nothing else except recording block with just one object creation.

NOTE: It's not .NET object, it's object, created by adding reference to the COM type library (.tlb). So, I'm not sure I can mock it. In docs I found:
Known Issues and Limitations
...
TypeMock.NET does not support PInvoke methods.
...

So, the question: Can I mock objects and calls to the objects created by adding reference to the COM type library (.tlb) ?
answered by tom3m (9.7k points)
0 votes
Hi,

As far as we know what you are trying to do should be possible.

Did you look at the tracer to see the calls being issued on BVDBSLib.PtBvRoot?

Anyway, I suggest we take it offline to see the exact problem. I will send you a mail with the details.
answered by lior (13.2k points)
...