示例#1
0
 protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, PropertyValueProviderState providerState)
 {
     return(Task.FromResult(ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(
                                parent,
                                providerState.ProjectConfiguration,
                                providerState.Property,
                                _properties)));
 }
        public void WhenPropertiesAreNotRequested_PropertyValuesAreNotReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateConfigurationDimensionAvailableStatus();

            var entityRuntime = IEntityRuntimeModelFactory.Create();
            var dimension     = new KeyValuePair <string, string>("AlphaDimension", "AlphaDimensionValue");

            var result = (ConfigurationDimensionValue)ConfigurationDimensionDataProducer.CreateProjectConfigurationDimension(entityRuntime, dimension, properties);

            Assert.Throws <MissingDataException>(() => result.Name);
            Assert.Throws <MissingDataException>(() => result.Value);
        }
        public void WhenPropertiesAreRequested_PropertyValuesAreReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateConfigurationDimensionAvailableStatus(includeAllProperties: true);

            var entityRuntime = IEntityRuntimeModelFactory.Create();
            var dimension     = new KeyValuePair <string, string>("AlphaDimension", "AlphaDimensionValue");

            var result = (ConfigurationDimensionValue)ConfigurationDimensionDataProducer.CreateProjectConfigurationDimension(entityRuntime, dimension, properties);

            Assert.Equal(expected: "AlphaDimension", actual: result.Name);
            Assert.Equal(expected: "AlphaDimensionValue", actual: result.Value);
        }
示例#4
0
        public void WhenCreatingEntitiesFromAProjectConfiguration_OneEntityIsCreatedPerDimension()
        {
            var properties = PropertiesAvailableStatusFactory.CreateConfigurationDimensionAvailableStatus(includeAllProperties: true);

            var entityRuntimeModel = IEntityRuntimeModelFactory.Create();
            var configuration      = ProjectConfigurationFactory.Create("Alpha|Beta|Gamma", "A|B|C");
            var results            = ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(entityRuntimeModel, configuration, properties);

            // We can't guarantee an order for the dimensions, so just check that all the expected values are present.
            Assert.Contains(results, entity => entity is ConfigurationDimensionValue dimension && dimension.Name == "Alpha" && dimension.Value == "A");
            Assert.Contains(results, entity => entity is ConfigurationDimensionValue dimension && dimension.Name == "Beta" && dimension.Value == "B");
            Assert.Contains(results, entity => entity is ConfigurationDimensionValue dimension && dimension.Name == "Gamma" && dimension.Value == "C");
        }
        public void WhenThePropertyIsConfigurationIndependent_ThenNoDimensionsAreProduced()
        {
            var properties = PropertiesAvailableStatusFactory.CreateConfigurationDimensionAvailableStatus(includeAllProperties: true);

            var parentEntity  = IEntityWithIdFactory.Create("ParentKey", "ParentKeyValue");
            var configuration = ProjectConfigurationFactory.Create("Alpha|Beta|Gamma", "A|B|C");
            var property      = IPropertyFactory.Create(
                dataSource: IDataSourceFactory.Create(hasConfigurationCondition: false));

            var results = ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(parentEntity, configuration, property, properties);

            Assert.Empty(results);
        }
        public void WhenThePropertyIsConfigurationDependent_OneEntityIsCreatedPerDimension()
        {
            var properties = PropertiesAvailableStatusFactory.CreateConfigurationDimensionAvailableStatus(includeAllProperties: true);

            var parentEntity  = IEntityWithIdFactory.Create("ParentKey", "ParentKeyValue");
            var configuration = ProjectConfigurationFactory.Create("Alpha|Beta|Gamma", "A|B|C");
            var property      = IPropertyFactory.Create(
                dataSource: IDataSourceFactory.Create(hasConfigurationCondition: true));

            var results = ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(parentEntity, configuration, property, properties);

            // We can't guarantee an order for the dimensions, so just check that all the expected values are present.
            Assert.Contains(results, entity => entity is ConfigurationDimensionValue {
                Name: "Alpha", Value: "A"
            });
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property))
            {
                try
                {
                    foreach (IEntityValue dimension in ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(request.QueryExecutionContext.EntityRuntime, configuration, property, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(dimension, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }