What is the most convenient way of specifying a sequence of return value from a certain method, when using Rhino Mocks ?
For example, assume that you would like to implement a Test Stub for returning some random integers within a certain interval (e.g. between 20 and 70 if you would want to use the values for some random ages for adult people). I am used to the Java framework Mockito, and with that framework you could do it easily like this, if you want the first invocation to return 37, the second to return 65 and so on: Randomizer randomizer = Mockito.mock(Randomizer.class); Mockito.when(randomizer.getRandomInteger(20, 70)).thenReturn(37).thenReturn(65).thenReturn(28).thenReturn(56).thenReturn(23); //Alternatively, you can do it even easier like this with Mockito: Mockito.when(randomizer.getRandomInteger(20, 70)).thenReturn(37, 65, 28, 56, 23); You can write code with a similar kind of syntax in Rhino Mocks, which compiles fine, but obviously the intended semantics/usage of the invocation of the method "Return" (and its returned type 'IMethodOptions') does not seem to be the same as the Mockito method "thenReturn", since the following code throw an exception (Rhino Mocks 3.6): MockRepository mocks = new MockRepository(); var randomizer = mocks.DynamicMock<Randomizer>(); SetupResult.For(randomizer.GetRandomInteger(20, 70)).Return(37).Return(65); / Tomas -- 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.
