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?
asked by tolisss (28.8k points)

6 Answers

0 votes
Hi
is it possible?

Yes, of course. :D
TypeMock can mock public,protected, internal and private methods, as well as static, virtual, events, delegates, properties and indexes.
answered by scott (32k points)
0 votes
yes it does but i think that the following should pass also

namespace MCH.test
{

   public abstract class abstractClass
   {
      protected Form persistForm;

      public abstractClass(Form persistForm)
      {
         this.persistForm = persistForm;
      }

      public Form PersistForm
      {
         set { persistForm = value; }
      }

      private void validateActiveControl(Form persistForm)
      {

      }
      public XPCollection Save()
      {
         validateActiveControl(persistForm);

         return null;
      }

   }

   public class Class1 : abstractClass
   {
      public Class1(Form form) : base(form)
      {
      }
   }

   [TestFixture]
   public class ClassName
   {
      [Test]
      public void MethodName()
      {
         MockManager.Init();
         Mock mock = MockManager.Mock(typeof (Class1));
         mock.ExpectCall("validateActiveControl").Args(Check.IsTypeOf(typeof (Form)));
         Class1 controller = new Class1(null);
         controller.Save();
      }
   }

}

instead i get the message :



No method validateActiveControl in type MCH.test.Class1 returns void
answered by tolisss (28.8k points)
0 votes
or maybe it works ok cuase if I opean my eyes and see better :oops: validateActiveControl is private to abstractClass so probably mock cannot see it.

but still want a way to not execute validateActiveControl any suggestions?
answered by tolisss (28.8k points)
0 votes
First of all i cannot figure a way of doing what u suggest ,and second i would like to continue my life with Type Mocks instead of Interface Mocks.

Couldn't TypeMock allows to mock private methods of inherited classes in a future version?
answered by tolisss (28.8k points)
0 votes
Hi,
I will add this request to a future release
Thanks for pointing out this scenario
answered by scott (32k points)
0 votes
This has been solved in version 2.2 :D
answered by richard (3.9k points)
...