I know I am using an older version, but is there a way to remove rules? We have many unit test drivers testing various rule states and scenarios - our problems come on every rebuild the rules may be added in different orders because the tests run in a pseudorandom order based on the rebuild. We have no way to control when our objects have different rules, and because we no longer have instance rules, we need to be able to remove the active rules before we add more rules to test those specific rules. Is this possible?
In short - no you cannot remove or clear rules.
But: you can create multiple complete RuleSet and switch between these in your code.
By default all rules are added to a "default" RuleSet.
I would however recommend to unit test your rules as well. Have a look at the RuleTutorial sample that includes some helper classes to make it easier to unit test BusinessRules.
Thanks for responding (sorry for the time difference).
I can't give you actual code snippets for many reasons, including the sheer amount of code, but if I understand what you say, maybe this hypothetical situation might be answered using rulesets.
We have cases where config files decide how the application can be run. If the user wants to switch to a different config file, a different set of rules may be run. Since we're unable to remove rules, could we use rulesets by, when loading/adding all rules, adding them to a specific ruleset relative to that config only (each one has a unique ID), and upon switching, no rules would be on the new config?
Would something like that work?
You would actually have to register all rulesets when AddBusinessRules is called (just once per-type). And then you could switch between rulesets.
Copyright (c) Marimer LLC