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 have UI classes like this:

class MyBaseForm : Form { ... }
class CustomerBaseForm : MyBaseForm { ... }
class WidgetCustomerForm : CustomerBaseForm { ... }

When I do this:

WidgetCustomerForm x = Isolate.Fake.Instance<WidgetCustomerForm>(Members.CallOriginal, ConstructorWillBe.Called, BaseConstructorWillBe.Ignored);

the base class ctors are not being called...unfortunately, I *WANT* the CustomerBaseForm.ctor and MyBaseForm.ctor to be called, but I don't want the Form.ctor to be called.

Is there any way to do this?
asked by dougclutter (3.5k points)

1 Answer

0 votes
Hi,

You can use the overload of Fake.Instance that get the type to ignore as the last parameter.
Change the code to this:
WidgetCustomerForm x = Isolate.Fake.Instance<WidgetCustomerForm>(Members.CallOriginal, ConstructorWillBe.Called, BaseConstructorWillBe.Ignored, typeof(Form)); 


Hope it helps.
answered by ohad (35.4k points)
...