<p>I want to assert that a method is called exactly one time. I'm using RhinoMocks 3.5.</p>



<p>Here's what I thought would work:</p>

<pre class="lang-cs prettyprint-override"><code>[Test]
public void just_once()
{
    var key = "id_of_something";

    var source = MockRepository.GenerateStub&lt;ISomeDataSource&gt;();
    source.Expect(x =&gt; x.GetSomethingThatTakesALotOfResources(key))
        .Return(new Something())
        .Repeat.Once();

    var client = new Client(soure);

    // the first call I expect the client to use the source
    client.GetMeMyThing(key);

    // the second call the result should be cached
    // and source is not used
    client.GetMeMyThing(key);
}
</code></pre>

<p>I want this test to fail if the second invocation of <code>GetMeMyThing()</code> calls <code>source.GetSomethingThatTakesALotOfResources()</code>.</p>

Here is what I just did (as recommended by
Ray Houston
). I would still appreciate a more elegant solution...
```
```
[Test]
public void just_once()
{
    var key = "id_of_something";

    var source = MockRepository.GenerateStub<ISomeDataSource>();

    // set a positive expectation
    source.Expect(x => x.GetSomethingThatTakesALotOfResources(key))
        .Return(new Something())
        .Repeat.Once();

    var client = new Client(soure);

    client.GetMeMyThing(key);

    // set a negative expectation
    source.Expect(x => x.GetSomethingThatTakesALotOfResources(key))
        .Return(new Something())
        .Repeat.Never();

    client.GetMeMyThing(key);
}
```
```