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

is it possible to know if MockManger has been initialize so i can initializing at run time if it isn't?

sometimg like
if (!MockManager.IsInit)
  MockManager.Init
asked by tolisss (28.8k points)

7 Answers

0 votes
is it possible to know if MockManger has been initialize so i can initializing at run time if it isn't?

There is no API to know if MockManager has been initialize.
Just out of curiosity, why would you want to know this?
answered by richard (3.9k points)
0 votes
suppose that i have a method with an argument of type Mock i would like to know if the Manager has been initialized. Now i m doing it like this
public bool IsManagerInit()
      {
         try
         {
            Mock mock=MockManager.Mock(typeof(Hashtable));
         }
         catch (VerifyException)
         {
            return false;
         }
         return true;
      }

but it would be nice if a static method exist on the MockManager class
answered by tolisss (28.8k points)
0 votes
Hi,
Your code snippet will work (although I agree that it is better to have an IsInitialized property), what I would like to understand is what case are you using this, to see if it is something that all TDD developers would need or if it is something that is perticular to your project.

Wouldn't doing a MockManager.Init before each test solve this?
Are you putting code in you production area?
Are you creating some test setup code (Like a Mock factory)?
answered by richard (3.9k points)
0 votes
i m trying to build a test framework for testing gridControls and some methods need an argument of Mock type so i need to now inside those methods if the manager is Init
answered by tolisss (28.8k points)
0 votes
Hi,
I will add this request to future version
answered by richard (3.9k points)
0 votes
thnks :) also this addition will be nice
[url]
https://www.typemock.com/community/viewt ... =hashtable
[/url]
answered by tolisss (28.8k points)
0 votes
Hi,
:D In version 2.2 there is a new Property: MockManager.IsInitialized,
answered by richard (3.9k points)
...