Current status of sequences in Moq

4 views
Skip to first unread message

Brian J. Cardiff

unread,
Nov 21, 2009, 2:53:59 PM11/21/09
to moq...@googlegroups.com
I want to clarify a bit what I've been thinking and doing for this.

My intention was to improve mock in order to support different kind of extensions with minimum impact on the core. Many of you have different thought on what a nice api and behavior would be for sequences. Some only regarding successive returns of a methods, others about interaction of many mocks.

What I tried was to add a .When(Func<bool>) at the beginning, before the setup. This condition rules when the following expectation applies. This had some impact with the default override behavior, but backward compatibility is maintained.

Using that simple, but powerfull extension some of the scenarios you wanted were implemented. They are not at trunk yet. Some pending discussion are pending.

If you want a preview of the current supported samples in branch /branches/private/bcardiff/ConditionalSetups/ browse the follwing samples

Also, there are some pending issues that will imply some code, but I think the main work is already done.

* Show where in the sequence the trace stoped. To improve error reporting. Similar to .VerifyAll()
* Support all overloads Func<...>, Action<...>
* Support properties, not only methods.

Brian J. Cardiff
bcardiff(?)gmail.com
.

Daniel Cazzulino

unread,
Nov 21, 2009, 6:26:26 PM11/21/09
to moq...@googlegroups.com
I like the senquencing stuff Brian! Great work and very nice API :)

One minor thing is why we need to use SetupSequentials instead of making it implicit by enabling multiple calls to Returns directly...

/kzu

--
Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1 425.329.3471


Brian J. Cardiff

unread,
Nov 22, 2009, 2:26:16 AM11/22/09
to moq...@googlegroups.com
That maybe another way to implement it. I just need a way to define the language that allow multiple calls to Returns. Please, review how I handle this and tell me if you find a way to reuse better all the interfaces that define the language. Either for Sequence it self, or for the conditional setups (When).

We (or me) should complete basic functionality an see if it can be merged on trunk. I think is the best approach I had accomplish for the Sequence stuff.

Brian J. Cardiff
bcardiff(?)gmail.com
.


Reply all
Reply to author
Forward
0 new messages