public void WhenPropertiesAreNotRequested_PropertyValuesAreNotReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateUIEditorMetadataAvailableStatus(includeAllProperties: false);

            var entityRuntime = IEntityRuntimeModelFactory.Create();
            var metadata      = new NameValuePair {
                Name = "Alpha", Value = "AlphaValue"
            };

            var result = (UIEditorMetadataValue)UIEditorMetadataProducer.CreateMetadataValue(entityRuntime, metadata, properties);

            Assert.Throws <MissingDataException>(() => result.Name);
            Assert.Throws <MissingDataException>(() => result.Value);
        }
        public void WhenPropertiesAreRequested_PropertyValuesAreReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateUIEditorMetadataAvailableStatus(
                includeName: true,
                includeValue: true);

            var entityRuntime = IEntityRuntimeModelFactory.Create();
            var metadata      = new NameValuePair {
                Name = "Alpha", Value = "AlphaValue"
            };

            var result = (UIEditorMetadataValue)UIEditorMetadataProducer.CreateMetadataValue(entityRuntime, metadata, properties);

            Assert.Equal(expected: "Alpha", actual: result.Name);
            Assert.Equal(expected: "AlphaValue", actual: result.Value);
        }
Beispiel #3
0
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));

            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is ValueEditor editor)
            {
                try
                {
                    foreach (IEntityValue metadataValue in UIEditorMetadataProducer.CreateMetadataValues(request.RequestData.EntityRuntime, editor, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(metadataValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public void WhenCreatingMetadataFromAnEditor_AllMetadataIsReturned()
        {
            var properties = PropertiesAvailableStatusFactory.CreateUIEditorMetadataAvailableStatus(
                includeName: true,
                includeValue: true);

            var parentEntity = IEntityWithIdFactory.Create("ParentKey", "ParentKeyValue");
            var editor       = new ValueEditor
            {
                Metadata =
                {
                    new() { Name = "Alpha", Value = "A" },
                    new() { Name = "Beta",  Value = "B" }
                }
            };

            var results = UIEditorMetadataProducer.CreateMetadataValues(
                parentEntity,
                editor,
                properties);

            Assert.Contains(results, entity => entity is UIEditorMetadataValue metadata && metadata.Name == "Alpha" && metadata.Value == "A");
            Assert.Contains(results, entity => entity is UIEditorMetadataValue metadata && metadata.Name == "Beta" && metadata.Value == "B");
        }
Beispiel #5
0
 protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, ValueEditor providerState)
 {
     return(Task.FromResult(UIEditorMetadataProducer.CreateMetadataValues(parent, providerState, _properties)));
 }