Hi Honggoff,

for me this seems to be some undesired behavior in a corner case (you could 
also call it a bug). The problem is that BachToRecordAll seems to only 
remove expectations on the "root-Recorder", but the mock.Unordered() 
introduces a new "sub-recorder". So in this case BackToRecorded changes 
nothing ;-)

Maybe I'll take a look at the code and try to find a useful solution during 
the next days.

But one annotation - I don't know your concrete scenario, but I'll find it 
quite curious that you'll use Ordered/Unordered-Expectations together with 
some resting of expectations, because I can only imagine that you'll need 
this for a very complex/hard to understand test?

Br,

Andreas

Am Dienstag, 20. März 2012 14:38:07 UTC+1 schrieb honggoff:
>
> Hi,
> while tracking down an error in a unit test, I came across some (IMO) odd 
> behavior of BackToRecordAll. I boiled it down to the following test case:
>
>     public interface IDummy
>     {
>       bool GetValue();
>     }
>
>     [Test]
>     public void TestBackTorecordAll()
>     {
>       MockRepository mock = new MockRepository();
>       IDummy test = mock.StrictMock<IDummy>();
>
>       using (mock.Unordered())
>       {
>         Expect.Call(test.GetValue())
>           .Return(true)
>           .Repeat.AtLeastOnce();
>       }
>       mock.ReplayAll();
>
>       Assert.IsTrue(test.GetValue());
>       mock.VerifyAll();
>
>       mock.BackToRecordAll(BackToRecordOptions.All);
>       Expect.Call(test.GetValue())
>         .Return(false)
>         .Repeat.AtLeastOnce();
>
>       mock.ReplayAll();
>       Assert.IsFalse(test.GetValue());
>
>       mock.VerifyAll();
>     }
>
> This test case fails. Is this the expected behavior? If so, why does the 
> test succeed, if i remove the mock.Unordered() call?
>
> Maybe I'm misunderstanding what BackToRecordAll does. I expected it to go 
> back to record mode and reset all expectations.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhinomocks/-/yZK8xjFLFEsJ.
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