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 am using Typemock Isolater version 5.4.5.0 with Visual Studio 2005.

I have a COM object accessed through COM Interop and an interop assembly that I want to use in my testing, but I need to fake one method/property.

When I execute the following:


DMFlowtableSheetClass _fakeSheet = Isolate.Fake.Instance<DMFlowtableSheetClass>();
Isolate.WhenCalled<string>(
delegate(string s)
{
return _fakeSheet.get_SubFlowtables(s);
}
).AndArgumentsMatch((Func<string>)
delegate
{
return true;
}
).WillReturn(null);

“fakeSheet.get_SubFlowtables(s)” in the WhenCalled delegate calls the actual object regardless of what I specify for the Members enum on the call to Isolate.Fake.Instance. I’ve tried passing in Members.ReturnRecursiveFakes, but it still calls’ the original method.

In all cases I want to call the original method/properties, except when calling get_SubFlowtables.

How do I make this work?
asked by Streitfeld (600 points)

2 Answers

0 votes
Hi,

The test seems to be written correctly, so all methods should have been faked. Is it possible to send a small project that reproduces it support at typemock.com?

We'll reproduce it here and see what happens in this case.

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Looking again at the test, I see a couple of things you can try first:
:arrow: using AndArgumentsMatch is redundant in this case, as you are not returning value based on arguments. Just omit the call and use WhenCalled with a parameterless delegate.
:arrow: If you want the object's original behavior, but just want to fake out one call, you can create the object normally and fake out that specific call
:arrow: If you don't have access to the object's constructor you can specify Members.CallOriginal in Isolate.Fake.Instance() to achieve similar results.

This would look something like this:
var testSheet = new DMFlowtableSheetClass(); //or any other way to initialize this object
Isolate.WhenCalled(() => testSheet.get_SubFlowtables("")).ReturnRecrusiveFake();


Please let us know if this works.
Doron
Typemock Support
answered by doron (16.5k points)
...