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 i m using the following code
using MbUnit.Core.Framework;
using MbUnit.Framework;
using TypeMock;

namespace MCH.Fixtures
{
   [TestFixture]
   public class Class2
   {
      [Test]
      public void Test()
      {
         MockManager.Init();
         TestedClass t = new TestedClass();
         t.doSomething();
         t.doSomething();
         t.doSomething();
         Assert.AreEqual(3,MockManager.CalledCounter("MCH.Fixtures.TestedClass","doSomething"));
      }
   }
   public class TestedClass
   {
      public void doSomething()
      {
      }
   }
}


but the assertion fails [[3]]!=[[0]] :? why? its just copy paste from the help
asked by tolisss (28.8k points)

2 Answers

0 votes
Hi,
First I am sorry that it took us soo long to answer, there must be a time difference between our locations.

You have found a bug in the documentation :oops:. By default, TypeMock collects call statistics, only for mocked types.
To enable collecting calls for all types, do one of the following:
:arrow: 1. MockManager.Init(true)
or
:arrow: 2. MockManager.CollectAllCalls = true;

so the code will look like this: :idea: Notice the Init statement

using MbUnit.Core.Framework;
using MbUnit.Framework;
using TypeMock;

namespace MCH.Fixtures
{
   [TestFixture]
   public class Class2
   {
      [Test]
      public void Test()
      {
         MockManager.Init(true);
         TestedClass t = new TestedClass();
         t.doSomething();
         t.doSomething();
         t.doSomething();
         Assert.AreEqual(3,MockManager.CalledCounter("MCH.Fixtures.TestedClass","doSomething"));
      }
   }
   public class TestedClass
   {
      public void doSomething()
      {
      }
   }
}


We have fixed the documentation and it will be contained in our next release. Thank you for pointing this out to us
answered by scott (32k points)
0 votes
Hi,
The documentation has been fixed, and an error is thrown if CollectAllCalls is not set, before using CalledCounter.
answered by richard (3.9k points)
...