Repeat.Any breaks the ordering - note the code documentation for Any. Your 'workaround' is ok. You could also try AtLeastOnce, if it is what you are looking for.
On 6 Feb., 19:31, Nathan <[email protected]> wrote: > Hello, I'm trying to do the following: > > // Define expected function calls > using (this.mocks.Ordered()) > { > Expect.Call(this.slpaPort.IsOpen).Return(false); > Expect.Call(this.slpaPort.Open); > Expect.Call(this.slpaPort.IsOpen).Return > (true).Repeat.Any(); > } > Expect.Call(delegate { this.slpaPort.Write(new byte[] > { 0x40, 0x92, 0xCB }); }); > > But this doesn't work, The first call to the property slpaPort.IsOpen > returns true when I would expect false. Changing Any() to Times(1, > int.MaxValue) does work, and the first call to the property returns a > false. > > // Define expected function calls > using (this.mocks.Ordered()) > { > Expect.Call(this.slpaPort.IsOpen).Return(false); > Expect.Call(this.slpaPort.Open); > Expect.Call(this.slpaPort.IsOpen).Return > (true).Repeat.Times(1, int.MaxValue); > } > Expect.Call(delegate { this.slpaPort.Write(new byte[] > { 0x40, 0x92, 0xCB }); }); > > This is Rhino Mocks 3.5 for .Net 2.0. > > I tried make an internal unordered block, but that didn't help because > the unordered block would never exit. > > For now I guess I'll use the work around I've shown. > > Thanks, > > Nathan Brown --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
