public void WhenCallingIsRegisteredForARuleHasBeenRegistered() { var rule = new RuleThatWillAlwaysPass(); RulesInitializer.RegisterRule<IAccountBalanceRules, decimal>(typeof(Account), () => rule); Func<bool> should_return_true_for_the_registered_rule = Rule<RuleThatWillAlwaysPass>.IsRegisteredFor<Account>; Assert.IsTrue(should_return_true_for_the_registered_rule()); }
public void GetRulesFor_ReturnsAllRegisteredRules() { var rule = new RuleThatWillAlwaysPass(); RulesInitializer.RegisterRule<IAccountBalanceRules, decimal>(typeof(Account), () => rule); var rules = RulesProvider.GetRulesFor<IAccountBalanceRules, decimal>(typeof(Account)); Assert.AreEqual(typeof(MeetsTheMinimumRequiredAccountBalance), rules.ToList()[0].Invoke().GetType()); Assert.AreEqual(typeof(RuleThatWillAlwaysPass), rules.ToList()[1].Invoke().GetType()); }