Brian,
The approach with ExpectFirst(), ExpectNext() is viable, but I can
suggest a more streamlined and flexible one, based on external
coordinator. Something like:
MockSequence sequence = new MockSequence();
mocked = new Mock<IFoo>();
mocked2 = new Mock<IFoo>();
mocked.InSequence(sequence).Expect(x => x.Method1()));
mocked.InSequence(sequence).Expect(x => x.Method2()));
mocked.Expect(x => x.Method3())); // this one is not participating in
sequence check
mocked.InSequence(sequence).Expect(x => x.Method4()));
mocked2.InSequence(sequence).Expect(x => x.Method1()));
The expected sequence is now mocked.Method1, mocked.Method2,
mocked.Method4, and mocked2.Method1
So you can (if you want) specify sequence across multiple mocks, as
well as within the same mock. You can also have an expectation
participate in multiple sequences.
Thanks!
-Eugene
On Mar 13, 7:55 am, "Brian J. Cardiff" <
bcard...@gmail.com> wrote:
> Just because it was easier for me yesterday.
> Depending on feedback and some spike I would like to do, I will start an
> extensibility private branch.
>
> On Thu, Mar 13, 2008 at 12:05 AM, Daniel Cazzulino <
dan...@cazzulino.com>
> wrote:
>
>
>
>
>
> > I wonder why you didn't just use your private branch on Moq's SVN?
>
> > On Wed, Mar 12, 2008 at 8:41 PM, Brian J. Cardiff <
bcard...@gmail.com>
> > wrote:
>
> > > Eugene,
>
> > > As you point at the end of your message, you can do what you want with a
> > > bunch of Callbacks. Ugly code, but it can be done.
>
> > > IMO a better approach would be to create some extensions on top of Moq
> > > to get better test code for that scenario, do you agree?
>
> > > In that direction I was able to do a *partial* solution. You can look at
> > > my personal sandbox at http://<server>/svn/sandbox/trunk/MoQSamples/ with
> > > <server>=
pixpex.no-ip.com under the Extensibility project.
>
> > > The solution is *partial* since it only supports ordered expectations on
> .- Hide quoted text -
>
> - Show quoted text -