public void WhenPropertiesAreRequested_PropertyValuesAreReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateSupportedValuesPropertiesAvailableStatus(includeAllProperties: true);

            var entityRuntime = IEntityRuntimeModelFactory.Create();
            var enumValue     = IEnumValueFactory.Create(displayName: "Hello", name: "MyValue");

            var result = (SupportedValueValue)SupportedValueDataProducer.CreateSupportedValue(entityRuntime, enumValue, properties);

            Assert.Equal(expected: "Hello", actual: result.DisplayName);
            Assert.Equal(expected: "MyValue", actual: result.Value);
        }
        public async Task WhenCreatingValuesFromAnIProperty_WeGetOneValuePerIEnumValue()
        {
            var properties = PropertiesAvailableStatusFactory.CreateSupportedValuesPropertiesAvailableStatus(includeAllProperties: true);

            var parentEntity = IEntityWithIdFactory.Create("ParentKey", "ParentKeyValue");
            var iproperty    = IPropertyFactory.CreateEnum(new[]
            {
                IEnumValueFactory.Create(displayName: "Alpha", name: "a"),
                IEnumValueFactory.Create(displayName: "Beta", name: "b"),
                IEnumValueFactory.Create(displayName: "Gamma", name: "c")
            });

            var result = await SupportedValueDataProducer.CreateSupportedValuesAsync(parentEntity, iproperty, properties);

            Assert.Collection(result, new Action <IEntityValue>[]
            {
                entity => assertEqual(entity, expectedDisplayName: "Alpha", expectedValue: "a"),
                entity => assertEqual(entity, expectedDisplayName: "Beta", expectedValue: "b"),
                entity => assertEqual(entity, expectedDisplayName: "Gamma", expectedValue: "c")
            });
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));

            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (ProjectConfiguration _, ProjectSystem.Properties.IEnumProperty enumProperty))
            {
                try
                {
                    IEnumerable <IEntityValue> supportedValues = await SupportedValueDataProducer.CreateSupportedValuesAsync(request.RequestData.EntityRuntime, enumProperty, _properties);

                    foreach (IEntityValue supportedValue in supportedValues)
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(supportedValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
 protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, PropertyValueProviderState providerState)
 {
     return(SupportedValueDataProducer.CreateSupportedValuesAsync(parent, providerState.Property, _properties));
 }