protected async Task CheckRuleAsync(IBusinessRuleAsync rule) { if (await rule.IsBrokenAsync()) { throw new BusinessRuleValidationException(rule); } }
private async void RunAsyncRule(IBusinessRuleAsync asyncRule, IRuleContext context) { try { await asyncRule.ExecuteAsync(context); } finally { context.Complete(); } }
/// <summary> /// Initializes the test. /// </summary> /// <param name="rule">The rule.</param> /// <param name="target">The target BO.</param> public void InitializeTest(IBusinessRuleAsync rule, object target) { var services = new ServiceCollection(); services.AddCsla(); var provider = services.BuildServiceProvider(); var applicationContext = provider.GetRequiredService <ApplicationContext>(); Accessor = new ObjectAccessor(applicationContext); _ruleContextCompleteWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); AsyncRule = rule; RuleContext = new RuleContext(applicationContext, c => _ruleContextCompleteWaitHandle.Set(), rule, target, new Dictionary <IPropertyInfo, object>()); }
private async Task ExecuteRuleAsync(IBusinessRuleAsync rule, RuleContext context) { await rule.ExecuteAsync(context); }
public void InitTests() { Rule = new AsyncLookupCustomer(RootFake.CustomerIdProperty, RootFake.NameProperty); }