title: Moq - verify returns zero even though I can see the methods being called
body: <p>I am trying to verify that two methods get called only once, but I keep being told by mock that the actual times they were called was zero:</p>
  
  <pre><code>Moq.MockException: 
  Expected invocation on the mock exactly 1 times, but was 0 times: x =&gt; x.Map(.OrderType)
  No setups configured.
  No invocations performed.
     at Moq.Mock.ThrowVerifyException(MethodCall expected, IEnumerable`1 setups, IEnumerable`1 actualCalls, Expression expression, Times times, Int32 callCount)
     at Moq.Mock.VerifyCalls(Interceptor targetInterceptor, MethodCall expected, Expression expression, Times times)
     at Moq.Mock.Verify[T,TResult](Mock`1 mock, Expression`1 expression, Times times, String failMessage)
     at Moq.Mock`1.Verify[TResult](Expression`1 expression, Times times)
     at Ylp.Import.Sandwell.Tests.Factories.SandwellOperatingHoursFactoryTests.WhenInputValid.CallsRestrictionTypeMapper()
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>class SandwellOperatingHoursFactoryTestBase
      {
          protected OperatingHoursCms OperatingHoursCms;
          protected virtual Mock&lt;IMap&lt;string, RuleTimeCms&gt;&gt; RuleTimeMapperMock =&gt; new Mock&lt;IMap&lt;string, RuleTimeCms&gt;&gt;();
          protected virtual Mock&lt;IMap&lt;string, UkRestrictionTypes.Entry&gt;&gt; RestrictionTypeMapperMock =&gt; new Mock&lt;IMap&lt;string, UkRestrictionTypes.Entry&gt;&gt;();
  
          protected virtual string OrderType =&gt; null;
          protected virtual string TimesOfEnforcement =&gt; null;
  
          protected RuleTimeCms ReturnedRuleTimeCms =&gt; null;
          protected UkRestrictionTypes.Entry ReturnedRestrictionTypeEntry =&gt; null;
  
      }
  
      internal class SandwellOperatingHoursFactoryCreateTestBase: SandwellOperatingHoursFactoryTestBase
      {
          [TestInitialize]
          public void Initialize()
          {
              RestrictionTypeMapperMock.Setup(x =&gt; x.Map(OrderType)).Returns(ReturnedRestrictionTypeEntry);
              RuleTimeMapperMock.Setup(x =&gt; x.Map(TimesOfEnforcement)).Returns(ReturnedRuleTimeCms);
  
  
              OperatingHoursCms = new SandwellOperatingHoursFactory(RuleTimeMapperMock.Object,RestrictionTypeMapperMock.Object).Create(OrderType,TimesOfEnforcement);
          }
      }
  
      [TestClass]
      internal class WhenInputValid: SandwellOperatingHoursFactoryCreateTestBase
      {
          [TestMethod]
          public void CallsRuleTimeMapper()
          {
              RuleTimeMapperMock.Verify(x=&gt;x.Map(TimesOfEnforcement),Times.Once);
          }
  
          [TestMethod]
          public void CallsRestrictionTypeMapper()
          {
              RestrictionTypeMapperMock.Verify(x =&gt; x.Map(OrderType), Times.Exactly(1));
          }
      }
  
      class SandwellOperatingHoursFactory
      {
          private IMap&lt;string, RuleTimeCms&gt; _ruleTimeMapper;
          private IMap&lt;string, UkRestrictionTypes.Entry&gt; _restrictionTypeMapper;
          internal SandwellOperatingHoursFactory(
              IMap&lt;string, RuleTimeCms&gt; ruleTimeMapper, 
              IMap&lt;string, UkRestrictionTypes.Entry&gt; restrictionTypeMapper)
          {
              _ruleTimeMapper = ruleTimeMapper;
              _restrictionTypeMapper = restrictionTypeMapper;
          }
  
          public OperatingHoursCms Create(string orderType, string timesOfEnforcement)
          {
              var ruleTime = _ruleTimeMapper.Map(timesOfEnforcement);
              var restrictionType = _restrictionTypeMapper.Map(orderType);
  
              return null;
          }
      }
  </code></pre>