Example #1
0
        public void WhenCreatingCategoriesFromARule_OneEntityIsCreatedPerCategory()
        {
            var properties = PropertiesAvailableStatusFactory.CreateCategoryPropertiesAvailableStatus(includeAllProperties: true);

            var context      = IQueryExecutionContextFactory.Create();
            var parentEntity = IEntityWithIdFactory.Create(key: "A", value: "B");
            var rule         = new Rule
            {
                Categories =
                {
                    new()
                    {
                        Name        = "Alpha",
                        DisplayName = "First category"
                    },
                    new()
                    {
                        Name        = "Beta",
                        DisplayName = "Second category"
                    }
                }
            };

            var result = CategoryDataProducer.CreateCategoryValues(context, parentEntity, rule, properties);

            Assert.Collection(result, new Action <IEntityValue>[]
            {
                entity => { assertEqual(entity, expectedName: "Alpha", expectedDisplayName: "First category"); },
                entity => { assertEqual(entity, expectedName: "Beta", expectedDisplayName: "Second category"); }
            });
Example #2
0
        protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ContextAndRuleProviderState providerState)
        {
            (string versionKey, long versionNumber) = providerState.ProjectState.GetUnconfiguredProjectVersion();
            queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

            return(Task.FromResult(CategoryDataProducer.CreateCategoryValues(queryExecutionContext, parent, providerState.Rule, _properties)));
        }
        protected override async Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ContextAndRuleProviderState providerState)
        {
            if (await providerState.ProjectState.GetMetadataVersionAsync() is (string versionKey, long versionNumber))
            {
                queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);
            }

            return(CategoryDataProducer.CreateCategoryValues(queryExecutionContext, parent, providerState.Rule, _properties));
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache _, Rule rule))
            {
                try
                {
                    foreach (IEntityValue categoryValue in CategoryDataProducer.CreateCategoryValues(request.RequestData, rule, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(categoryValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
Example #5
0
 protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, PropertyPageProviderState providerState)
 {
     return(Task.FromResult(CategoryDataProducer.CreateCategoryValues(parent, providerState.Rule, providerState.DebugChildRules, _properties)));
 }