What bothers me is that this interface doesn't just encapsulate which calls should be matched, but also how these calls should behave
Yeah, I was tracking down the interfaces we return from the various
A.CallToSets (and extensions such as
To) and wondering if we could provide a very narrow interface that's all about the call validation.
it would be a significant refactoring, I think.
Well, we are about to break things anyhow. Then again, we'd need to look at the scope of the breakage and balance it against the utility of the feature.
MutableCallRule. If we introduce something like
AsRule()like in my example above, the rule that is returned should really be a snapshot of the state of the rule when
AsRule()is called. Otherwise, we could have things like this:
var callToConfigure = A.CallTo(() => fake.Foo()); var rule = call.AsRule(); callToConfigure.Where(... ) // rule modified here .Returns(42);
AsRuleto begin with. I'd rather have immutable rules inside.
And it could directly implement IFakeObjectRule (or at least a new interface that exposes IsApplicableTo)
Or maybe not, because then
IsApplicableTo would show up in Intellisense for configuration interfaces, which would be messy
Throws, etc) would work with that.