public async Task WhenThePropertyIsConfigurationIndependent_ThenOnlyOneValueIsReturned() { var parent = IEntityWithIdFactory.Create(key: "ParentName", value: "Aardvark"); var defaultConfiguration = ProjectConfigurationFactory.Create("Alpha|Beta"); var otherConfiguration = ProjectConfigurationFactory.Create("Delta|Gamma"); var cache = IPropertyPageQueryCacheFactory.Create( projectConfigurations: ImmutableHashSet <ProjectConfiguration> .Empty.Add(defaultConfiguration).Add(otherConfiguration), defaultConfiguration: defaultConfiguration, bindToRule: (config, schemaName) => IRuleFactory.Create( name: "ParentName", properties: new[] { IPropertyFactory.Create("MyProperty") })); var schema = new Rule { Properties = { new TestProperty { Name = "MyProperty", DataSource = new(){ HasConfigurationCondition = false } } } }; var propertyName = "MyProperty"; var requestedProperties = PropertiesAvailableStatusFactory.CreateUIPropertyValuePropertiesAvailableStatus(); var results = await UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync( parent, cache, schema, propertyName, requestedProperties); Assert.Single(results); }
public async Task WhenPropertyIsAnIEvaluatedProperty_GetUnevaluatedValueAsyncIsCalled() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyValuePropertiesAvailableStatus( includeEvaluatedValue: false, includeUnevaluatedValue: true); var mockEvaluatedProperty = new Mock <IEvaluatedProperty>(); mockEvaluatedProperty.Setup(m => m.GetUnevaluatedValueAsync()).ReturnsAsync("unevaluated value"); var property = mockEvaluatedProperty.Object; var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var configuration = ProjectConfigurationFactory.Create(configuration: "Alpha|Beta|Gamma"); var result = (UIPropertyValueValue)await UIPropertyValueDataProducer.CreateUIPropertyValueValueAsync( entityRuntime, id, configuration, property, properties); Assert.Equal(expected: "unevaluated value", actual: result.UnevaluatedValue); mockEvaluatedProperty.Verify(m => m.GetUnevaluatedValueAsync()); }
public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request) { if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache cache, Rule schema, string propertyName)) { try { IEnumerable <IEntityValue> propertyValues = await UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync( request.RequestData, cache, schema, propertyName, _properties); foreach (IEntityValue propertyValue in propertyValues) { await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyValue, request, ProjectModelZones.Cps)); } } catch (Exception ex) { request.QueryExecutionContext.ReportError(ex); } } await ResultReceiver.OnRequestProcessFinishedAsync(request); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, PropertyProviderState providerState) { return(UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync( parent, providerState.Cache, providerState.ContainingRule, providerState.PropertyName, _properties)); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, PropertyProviderState providerState) { return(UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync( queryExecutionContext, parent, providerState.ProjectState, providerState.ContainingRule, providerState.PropertiesContext, providerState.PropertyName, _properties)); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, PropertyProviderState providerState) { (string versionKey, long versionNumber) = providerState.ProjectState.GetUnconfiguredProjectVersion(); queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber); return(UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync( queryExecutionContext, parent, providerState.ProjectState, providerState.ContainingRule, providerState.PropertiesContext, providerState.PropertyName, _properties)); }
public async Task WhenThePropertyIsAnIIntProperty_ThenTheEvaluatedValueIsAnInt() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyValuePropertiesAvailableStatus(includeEvaluatedValue: true); var mockIntProperty = new Mock <IIntProperty>(); mockIntProperty.Setup(m => m.GetValueAsIntAsync()).ReturnsAsync(42); var property = mockIntProperty.Object; var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var configuration = ProjectConfigurationFactory.Create(configuration: "Alpha|Beta|Gamma"); var result = (UIPropertyValueValue)await UIPropertyValueDataProducer.CreateUIPropertyValueValueAsync( entityRuntime, id, configuration, property, properties); Assert.Equal(expected: 42, actual: result.EvaluatedValue); }