Exemple #1
0
 protected async Task CheckRuleAsync(IBusinessRuleAsync rule)
 {
     if (await rule.IsBrokenAsync())
     {
         throw new BusinessRuleValidationException(rule);
     }
 }
Exemple #2
0
 private async void RunAsyncRule(IBusinessRuleAsync asyncRule, IRuleContext context)
 {
     try
     {
         await asyncRule.ExecuteAsync(context);
     }
     finally
     {
         context.Complete();
     }
 }
Exemple #3
0
        /// <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>());
        }
Exemple #4
0
 private async Task ExecuteRuleAsync(IBusinessRuleAsync rule, RuleContext context)
 {
     await rule.ExecuteAsync(context);
 }
Exemple #5
0
 public void InitTests()
 {
     Rule = new AsyncLookupCustomer(RootFake.CustomerIdProperty, RootFake.NameProperty);
 }