Setup multiple returns on a method

54 views
Skip to first unread message

Shaunavon Blackmore

unread,
Dec 3, 2013, 3:48:47 PM12/3/13
to rhino...@googlegroups.com
I have a method that is called twice.  However, each time I call this method I would like to change the value on a property.  Below gives a simple explanation of what I am trying to achieve.

Actual C# method to test
public void  SomeMethod(string val1, string val2)
{
     var results1 = MyInterface.GetObjectResults(val1);

     foreach (record in results1)
     {
                var results2 = MyInterface.GetObjectResults(val2);    // same method as above

                if (results2.MyProperty != record.MyProperty) 
                {
                          //  TODO:
                }
     }
}


If I stub the MyInterface.GetObjectResults two times the results will be the same regardless of what values gets passed inside the method.  How can I stub this method differently so that both MyProperty value is not return to be the same?  Any help is greatly appreciated.

Iain Waddell

unread,
Dec 4, 2013, 3:25:57 AM12/4/13
to rhino...@googlegroups.com
Add .Repeat.Once() when setting the value.

Iain


--
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rhinomocks+...@googlegroups.com.
To post to this group, send email to rhino...@googlegroups.com.
Visit this group at http://groups.google.com/group/rhinomocks.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages