Hi Karl

I'm not sure, how to clear recorded methods,
but one solution can be you check that when you call ChangeRole second
time while Deselect role is pending,
logic calls SendDeselectRoleCadRequest just once

      [Test]
      public void
ChangeRole_WhenDeselectRoleIsPending_DoesNotCallSendDeselectRoleCadRequestAgain()
      {
         // Arrange
         InitializeObjectUnderTest();
         _logic.ChangeRole();

         // nice to have here some precondition
         Assert.That(_logic.IsDeselectRolePending, Is.True,
"Precondition: _logic.IsDeselectRolePending");

         // Act
         _logic.ChangeRole();

         // Assert
         DispServerConnection.AssertWasCalled(x =>
x.SendDeselectRoleCadRequest(), x => x.Repeat.Once());
      }


and maybe you need another test like this:

      [Test]
      public void
ChangeRole_WhenDeselectRoleIsFinished_CallsSendDeselectRoleCadRequestAgain()
      {
         // Arrange
         InitializeObjectUnderTest();
         _logic.ChangeRole();
         // something like this...
         _logic.ChangeRoleCompleted();

         // nice to have here some precondition
         Assert.That(_logic.IsDeselectRolePending, Is.False,
"Precondition: _logic.IsDeselectRolePending");

         // Act
         _logic.ChangeRole();

         // Assert
         DispServerConnection.AssertWasCalled(x =>
x.SendDeselectRoleCadRequest(), x => x.Repeat.Twice());
      }

bye
Rasto





On Apr 2, 11: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.

Reply via email to