title: How do I assert that a method is called only once?
body: <pre><code>[Subject(typeof(OnceADayProcessor))]
  public class When_processing_process_twice
  {
      private static ICanBeProcessedOnceADay ProcessedOnceADay;
  
      private Establish context = () =&gt; { OnceADayProcessor.Now = () =&gt; new DateTime(2011, 1, 1, 0, 0, 0, 0); };
  
      private Because of = () =&gt;
                               {
                                   ProcessedOnceADay = MockRepository.GenerateMock&lt;ICanBeProcessedOnceADay&gt;();
                                   ProcessedOnceADay.Process();
                                   ProcessedOnceADay.Process();
                               };
  
      private It should_execute = () =&gt; ProcessedOnceADay.AssertWasCalled(x =&gt; x.Expect(p =&gt; p.Process()));
      private It should_execute_only_once = () =&gt; ProcessedOnceADay.AssertWasNotCalled(x =&gt; x.Expect(p =&gt; p.Process()));
  }
  </code></pre>
  
  <p>edited solution:</p>
  
  <pre><code>[Subject(typeof(OnceADayProcessor))]
  public class When_processing_a_process_twice_at_the_same_day
  {
      static ICanBeProcessedOnceADay canBeProcessedOnceADay;
  
      Establish context = () =&gt;
      {
          canBeProcessedOnceADay = A.Fake&lt;ICanBeProcessedOnceADay&gt;();
      };
  
      Because of = () =&gt;
      {
          OnceADayProcessor.Process(canBeProcessedOnceADay);
          OnceADayProcessor.Process(canBeProcessedOnceADay);
      };
  
      It should_execute_only_once = () =&gt; 
          A.CallTo(() =&gt; canBeProcessedOnceADay.Process()).MustHaveHappened(Repeated.Exactly.Once);
  }
  </code></pre>