Hi Tim

I was wondering what your verdict was with the correct behaviour for
ordered returns, etc.
Have you had a look at my suggestion above?
I think that it would solve all ambiguity.

Mark Whitfeld
Habanero Development Team
http://www.habanerolabs.com

On Nov 23, 9:10 am, Mark Whitfeld <[email protected]> wrote:
> I would definitely agree that last in should win, but also that it
> would be nice to have something like what Tim suggested above.
> I thought of another syntax for this possibility. How about:
>
> mock.Stub(x=>x.Foo()).Return(1,2);
>
> This would just use a parameter array to specify the desired returns
> in order and therefore you would get the 'last in' winning and the
> desired ordered returns.
> What do you think?
>
> Mark Whitfeld
> Habanero Development Teamhttp://www.habanerolabs.com
>
> On Nov 22, 4:09 pm, Tim Barcz <[email protected]> wrote:
>
> > 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 
> > ASPInsiderhttp://timbarcz.devlicio.ushttp://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=en.


Reply via email to