I think it might be easier to just make an assertion that the
SendDeselectRoleCadRequest was only called once during your test.  I'm
pretty sure there's a way to do that.  If not, there's a method that
allows you to get the collection of arguments for each time a method
is called.  If the length of the collection is one, the method was
only called once.

---
Patrick Steele
http://weblogs.asp.net/psteele



On Fri, Apr 2, 2010 at 5:59 PM, Karl <[email protected]> wrote:
> Hi all,
>
> I want to test the following behaviour.
>
> When the method ChangeRole() of my object under test (variable name
> "_logic") is called and the same request is already pending the object
> under test should not send a second request to the server.
> The server is represented by the mock object "DispServerConnection".
>
> The precondition for my test would be to call the method ChangeRole.
> (Arrange)
> Then I call the method a second time (Act)
> And afterwards I assert that the SendDeselectRoleCadRequest method was
> not called on the DispServerConnection mock when the ChangeRole method
> was called a second time.
>
> The problem however is, that the test always fails because the method
> was actually called during the Arrange phase. So I'm wondering how I
> can tell my mock to "forget" everything it has recorded until now and
> start from scratch. Is this even possible without creating a fresh
> mock instance?
> In the Record/Replay model all recordings on a mock were cleared after
> calling Verify but I'm not sure how this is supposed to work in the
> AAA model.
>
>
>      public void
> ShouldNotSendDeselectRoleCadRequest_IfDeselectRoleRequestPending()
>      {
>         // Arrange
>         InitializeObjectUnderTest();
>         _logic.ChangeRole();
>         // How can I clear the recorded method calls on my mock
> here???
>
>         // Act
>         _logic.ChangeRole();
>
>         // Assert
>         DispServerConnection.AssertWasNotCalled(x =>
> x.SendDeselectRoleCadRequest());
>      }
>
> Thx for your help!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Rhino.Mocks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rhinomocks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to