There are cases where a call may be made twice and and each time you want
something different called.

mock.Stub(x=>x.Foo()).Return(1);
mock.Stub(x=>x.Foo()).Return(2);

Where the first call returns 1 and the second call returns 2.

If I can pull it off I was thinking of having the framework approach as
"last in wins" unless the expectation is explicitly set with a number of
times.  So in the example above, if you called Foo(), 2 would be returned
(last in winning).

However if you had:

mock.Stub(x=>x.Foo()).Return(1).Repeat.Once
mock.Stub(x=>x.Foo()).Return(2);

And then called Foo(), you would get 1 (since it was explicitly set up).

Again I don't know if this adds to the confusion or clears it up.


On Sun, Nov 22, 2009 at 7:38 AM, bill richards <[email protected]
> wrote:

> > looking at the example I think you might think that
> > it will create a queue of stubbed responses.
>
>
> Now that's just crazy talk! I write a fair number of C# classes, most
> of which contain at least one property getter and setter, for example:
>
> public SomeClass { public string Text { get; set; } }
>
> during the course of the application running, I might instantiate
> SomeClass thus:
>
> var sc = new SomeClass { Text = "First" };
>
> and then later on I might change the text thus:
>
> sc.Text = "Second";
>
> From what you have said above Alex, we should conclude that when
> running the following code:
>
> for(var i = 0; i < 2; i++)
> {
>   if(i == 0 && sc.Text == "First")
>       Console.WriteLine("First value retrieved");
>
>   if(i == 1 && sc.Text == "Second")
>       Console.WriteLine("Second value retrieved");
> }
>
>  I would expect the following output in my Command Window
>
> First value retrieved
> Second value retrieved
>
>
> but we all know that that is just nonsense .... so why would anyone
> expect different behaviour from a mocking framework?
>
> --
>
> 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]<rhinomocks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=.
>
>
>


-- 
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

--

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=.


Reply via email to