Interesting problem. So what you really want is to say that C must be
called after B and T must be called after S. Everything else you're
not bothered about the order.

You should be able to do this using some manual jiggery pokery. I'll
explain in the AAA syntax, but I can't see any reason you couldn't do
it with other syntaxes.

1. Create a bool 'BCalled'
2. Use RhinoMocks to perform an action when B is called
mock.Stub(x=>x.B()).WhenCalled(a=>{BCalled=true;});
3. Use RhinoMocks to check that BCalled is true when C is called:
mock.Stub(x=>x.C()).WhenCalled(a=>{Assert.IsTrue(BCalled,"C was called
before B);});

Note with the above that if neither B nor C is called the test would
pass so you might want to add an AssertWasCalled for C.
Also repeat the above for T and S.

There was some discussion about ordered expectations for AAA and the
above is what I did as a work-around. There was also a more thorough
implementation that you can read about here
http://kennethxu.blogspot.com/2009/06/rhinomocks-ordered-expectations-for-aaa.html
but as far as I know this hasn't got into Rhino Mocks yet.

Hope that helps

2009/9/17 jamesthurley <[email protected]>:
>
> I'm currently attempting to use Rhino Mocks to unit test a workflow we
> have created using Workflow Foundation 3.5.
>
> A simplified view of the start of our workflow looks like this:
>
> Sequence
> {
>  A()
>  Parallel
>  {
>    Sequence
>    {
>      B()
>      C()
>    }
>    Sequence
>    {
>      S()
>      T()
>    }
>  }
>  D()
> }
>
> Because WF executes the contents of parallel statements interleaved,
> the valid orders for the method calls here are:
>
> ABCSTD
> ABSCTD
> ABSTCD
> ASTBCD
> ASBTCD
> ASBCTD
>
> I've chosen the method names here to be the same as in the following
> post from 2006, because my problem is essentially the same as his:
>
> http://groups.google.co.uk/group/rhinomocks/browse_thread/thread/e4865d54554a6c09
>
> My attempt at mocking this was the same as the above post:
>
> using ( mocks.Ordered() )
> {
>  mock1.A();
>  using ( mocks.Unordered() )
>  {
>    using ( mocks.Ordered() )
>    {
>        mock1.B();
>        mock1.C();
>    }
>    using ( mocks.Ordered() )
>    {
>        mock1.S();
>        mock1.T();
>    }
>  }
>  mock1.D();
> }
>
> And the result was the same; that rhino mocks only allows:
>
> ABCSTD
> ASTCBD
>
> My workflow in reality contains hundreds of these calls being executed
> in sequence and in parallel.  This makes it impractical for me to
> anticipate how the Workflow Runtime will order it's parallel
> interleaved method calls.
>
> I can't just set everything to be unordered, as that doesn't test the
> ordering in any of the sequential blocks.
>
> As far as I know there is no way to stop Workflow Foundation from
> interleaving parallel blocks.
>
> Can anyone help with a practical solution to this problem?  Ideally a
> way to get Rhino Mocks to allow interleaving of ordered blocks within
> an unordered block.
>
> Cheers,
> James.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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