chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I use CSLA almost exclusively. In our tests, to keep them from being brittle I want to make sure I'm only turning on the rules I'm interested in checking. so ideally, part of my Arrange step would be to:

ValidationRules fakeRules = Isolate.Fake.Instance<ValidationRules>();


And since this object may have child objects (whose quantify might change depending on the test) who in turn have there own instances of ValidationRules I really need:

Isolate.Swap.AllInstances<ValidationRules>().With(fakeRules);


Now because I still want the rule I want to test to be ran (not faked) I need a specific call to call the original, not all - so in the below code, we don't care about rules X and Y, but we do want rule Z to be added (because we're testing against.

ValidationRules.AddRule(CheckRuleX, "X");
ValidationRules.AddRule(CheckRuleY, "Y");
ValidationRules.AddRule(CheckRuleZ, "Z");


So back to my test (and 'CheckRuleZ' is a delegate) I want:
Isolate.WhenCalled(() => fakeRules.AddRules(Arg.Is.Anything(), Arg<string>.Equals("Z"))).CallOriginal();


Yes, I borrowed the Arg thing from Rhino mocks, but when I'm working in that tool it is a helpful way of doing things. Basically I'm saying I want all AddRules call to be faked except for when I'm calling with specific parameters, and that first item of the parameter just to be anything (would be hard to pass what I'm looking for in this case), the second parameter I want to be 'Z'.

Let me know.
asked by boo (21.8k points)

3 Answers

0 votes
Hi Boo,

Unfortunately, you hit on a missing feature again :x . Faking all instances of a type (or MockAll as it's used in our previous generation APIs) is high on our todo list, and will be added in an upcoming version.

Thanks,
Doro
Typemock Support
answered by doron (17.2k points)
0 votes
Is handling different future instances differently based upon parameters passed into the method in the list too? That's as equally high for me as handling just generically 'all' future instances.
answered by boo (21.8k points)
0 votes
I've added your request to our feature list as well
answered by dhelper (11.9k points)
...