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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
+1 vote

Class example

{

     public example()

{

InitializeComponent();

_localize = new Localize(this);
   if (_localize == null)

{

-----

}

Showform f=new Showform ();

f.show(); //How to hide this form

f.refresh()

}

asked by (2.6k points)
edited by

1 Answer

0 votes
Hello gnanam,

If you wish to hide the form, you can use our IgnoreCall() API in your test. This is applicable to void methods only which matches your need.

Isolate.WhenCalled(() => f.show()).IgnoreCall();

Two more tips:

1. Do not forget to add a reference to System.Windows.Forms in your unit test project.

2. In order to verify that the test works, you can use the Verify API (this would be equivalent to \"Assert\" as a part of the AAA structure in unit testing). Syntax below:

 Isolate.Verify.WasCalledWithAnyArguments(() => f.Show()); //=False

The test should not pass.

Then, you can try

 Isolate.Verify.WasNotCalled(() => f.Show()) //=True

The test should pass now.

Let me know if this helps.

Cheers,

Coral
answered by (220 points)
Another class UI
...