public void VerifyThatGetPathWorks() { // **************************INPUT*************************************** var published = new ValueArray <string>(new List <string> { "manual1", "manual2" }, this.valueset); var actual = new ValueArray <string>(new List <string> { "manual1", "manual2" }, this.valueset); this.valueset.Published = published; this.valueset.Manual = actual; this.valueset.ValueSwitch = ParameterSwitchKind.MANUAL; this.valueset.ActualOption = this.option; var compoundtype = new CompoundParameterType(Guid.NewGuid(), null, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { ParameterType = this.parameterType1, ShortName = "c1" }; var component2 = new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { ParameterType = this.parameterType1, ShortName = "c2" }; compoundtype.Component.Add(component1); compoundtype.Component.Add(component2); var state2 = new ActualFiniteState(Guid.NewGuid(), null, this.uri); this.stateList.ActualState.Add(state2); this.parameter1.ParameterType = compoundtype; this.parameter1.ValueSet.Add(this.valueset); this.parameter1.IsOptionDependent = true; var valueset2 = new ParameterValueSet(Guid.NewGuid(), null, this.uri) { ActualState = state2, Published = published }; this.parameter1.ValueSet.Add(valueset2); var row = new ParameterRowViewModel(this.parameter1, this.option, this.session.Object, null); Assert.AreEqual(this.nestedParameterPath, row.GetPath()); var row2 = new ParameterTypeComponentRowViewModel(compoundtype.Component.First(), this.session.Object, null); Assert.AreEqual(string.Empty, row2.GetPath()); var row3 = new ParameterTypeComponentRowViewModel(compoundtype.Component.First(), this.session.Object, row); Assert.AreEqual(this.nestedParameterPath, row3.GetPath()); }
public void VerifyThatPopulateValuesForCompoundParameterTypesWorks() { this.parameterValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri) { ParameterType = null }; this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri)); var valueClone = this.parameterValue.Clone(false); this.requirementClone.ParameterValue.Add(valueClone); var vm = new SimpleParameterValueDialogViewModel(valueClone, this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone); var selectedParameter = new CompoundParameterType(); var parameterTypeComponent = new ParameterTypeComponent(); var selectedSimpleParameter = new SimpleQuantityKind(); parameterTypeComponent.ParameterType = selectedSimpleParameter; selectedParameter.Component.Add(parameterTypeComponent); vm.SelectedParameterType = selectedParameter; Assert.AreEqual(vm.Values.Count, 1); Assert.AreSame(vm.Values.First().ParameterType, selectedParameter); }
private void AddMembers(CompoundParameterType compoundParameterType, Assembly clientAssembly, IList <string> ancestorStack) { bool isWcfDataMember(MemberInfo member) { foreach (var attribute in WcfDataMemberAttributes) { if (member.GetCustomAttributes(attribute, true).Any()) { return(true); } } return(false); } var properties = compoundParameterType.Type .GetProperties() .Where(isWcfDataMember) .Select(x => new Parameter(x.Name, FromPreventStackOverflow(x.PropertyType, clientAssembly, compoundParameterType.Type, ancestorStack))); ((List <Parameter>)compoundParameterType.Members).AddRange(properties); var fields = compoundParameterType.Type .GetFields() .Where(isWcfDataMember) .Select(x => new Parameter(x.Name, FromPreventStackOverflow(x.FieldType, clientAssembly, compoundParameterType.Type, ancestorStack))); ((List <Parameter>)compoundParameterType.Members).AddRange(fields); }
/// <summary> /// Creates context menu for a <see cref="ParameterOverride"/> if it is an STEP 3D parameter. /// /// <seealso cref="IDstHubService.IsSTEPParameterType"/> /// </summary> /// <param name="parameter"><see cref="ParameterOverride"/> </param> private void ProcessParameterContextMenu(ParameterOrOverrideBase parameter) { if (!this.dstHubService.IsSTEPParameterType(parameter.ParameterType)) { return; } try { IValueSet valueSet = parameter.ValueSets.LastOrDefault(); var valuearray = valueSet.Computed; CompoundParameterType compound = (CompoundParameterType)parameter.ParameterType; var name_component = compound.Component.FirstOrDefault(x => x.ShortName == "name"); var source_component = compound.Component.FirstOrDefault(x => x.ShortName == "source"); var part_name = valuearray[name_component.Index]; var part_filereference = valuearray[source_component.Index]; this.fileRevisionId = part_filereference; this.ContextMenu.Add(new ContextMenuItemViewModel( $"Download Associated STEP 3D file to \"{part_name}\" {part_filereference}", "", this.DownloadGuidCommand, MenuItemKind.Export, ClassKind.NotThing)); } catch (Exception exception) { Logger.Warn(exception, "Ignoring context menue creation for ParameterOrOverride"); } }
public void VerifyToDtoMethodWithOrderedItem() { var compoundParameterType = new CompoundParameterType { Iid = Guid.NewGuid(), Container = this.srdl }; compoundParameterType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, null) { ShortName = "test1" }); compoundParameterType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, null) { ShortName = "test2" }); var dto = compoundParameterType.ToDto() as CDP4Common.DTO.CompoundParameterType; Assert.IsNotNull(dto); Assert.AreEqual(dto.Component.First().K, compoundParameterType.Component.SortedItems.Keys.First()); Assert.AreEqual(dto.Component.First().V, compoundParameterType.Component.SortedItems.Values.First().Iid); Assert.AreEqual(dto.Component.Last().K, compoundParameterType.Component.SortedItems.Keys.Last()); Assert.AreEqual(dto.Component.Last().V, compoundParameterType.Component.SortedItems.Values.Last().Iid); Assert.AreEqual(compoundParameterType.Route, dto.Route); Assert.AreEqual(compoundParameterType, dto.QuerySourceThing()); }
public void VerifyThatOwnerIsUpdatedForParameterOrOverride(IViewModelBase <Thing> container, string scenario) { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); parameter.Owner = this.activeDomain; var boolPt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); parameter.ParameterType = compoundParameterType; this.elementDefinition.Parameter.Add(parameter); var parameterSubscriptionRowViewModel = new ParameterRowViewModel(parameter, this.session.Object, container, false); var component1row = (ParameterComponentValueRowViewModel)parameterSubscriptionRowViewModel.ContainedRows.First(); Assert.IsTrue(component1row.OwnerName.Contains(this.activeDomain.Name)); this.activeDomain.Name = "updated"; this.activeDomain.RevisionNumber = 100; CDPMessageBus.Current.SendObjectChangeEvent(this.activeDomain, EventKind.Updated); Assert.IsTrue(component1row.OwnerName.Contains("updated")); }
public void VerifyFormatOfCompoundParameterType() { var compoundParameterType = new CompoundParameterType(); var format = NumberFormat.Format(compoundParameterType); Assert.AreEqual("@", format); }
public void VerifyThatTheSwitchIsUpdatedWhenContainerRowIsAParameterOrOverrideBaseRowViewModel() { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); var boolPt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); parameter.ParameterType = compoundParameterType; var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri); parameterOverride.Parameter = parameter; this.elementUsage.ParameterOverride.Add(parameterOverride); var parameterOverrideRowViewModel = new ParameterOverrideRowViewModel(parameterOverride, this.session.Object, null); var component1row = (ParameterComponentValueRowViewModel)parameterOverrideRowViewModel.ContainedRows.First(); var component2row = (ParameterComponentValueRowViewModel)parameterOverrideRowViewModel.ContainedRows.Last(); component1row.Switch = ParameterSwitchKind.COMPUTED; Assert.AreEqual(ParameterSwitchKind.COMPUTED, component2row.Switch); }
public void VerifyThatCompoundParameterOverrideReturnsExpectedModelCodeNoComponent() { var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "l" }; var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); compoundParameterType.ShortName = "coord"; var component = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = simpleQuantityKind }; component.ShortName = "x"; compoundParameterType.Component.Add(component); this.parameter.ParameterType = compoundParameterType; var parameterOverride = new ParameterOverride { Parameter = this.parameter }; this.elementUsage.ParameterOverride.Add(parameterOverride); Assert.AreEqual("Sat.battery_1.coord", parameterOverride.ModelCode()); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.permissionService = new Mock <IPermissionService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.session = new Mock <ISession>(); var person = new Person(Guid.NewGuid(), null, null) { Container = this.siteDir }; this.session.Setup(x => x.ActivePerson).Returns(person); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, null); this.siteDir.Person.Add(person); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null) { Name = "testRDL", ShortName = "test" }; this.compoundPt = new CompoundParameterType { Name = "parameterType", ShortName = "cat" }; this.cat = new Category(Guid.NewGuid(), this.cache, null) { Name = "category1", ShortName = "cat1" }; this.cat.PermissibleClass.Add(ClassKind.CompoundParameterType); this.srdl.DefinedCategory.Add(cat); this.siteDir.SiteReferenceDataLibrary.Add(this.srdl); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary)); this.bpt = new BooleanParameterType(Guid.NewGuid(), this.cache, null); this.cpt = new CompoundParameterType(Guid.NewGuid(), this.cache, null); this.srdl.ParameterType.Add(this.bpt); this.srdl.ParameterType.Add(this.cpt); this.qt = new SimpleQuantityKind(Guid.NewGuid(), this.cache, null); this.srdl.ParameterType.Add(this.qt); this.scale = new OrdinalScale(Guid.NewGuid(), this.cache, null); this.srdl.Scale.Add(this.scale); this.qt.PossibleScale.Add(this.scale); this.cache.TryAdd(new CacheKey(this.srdl.Iid, null), new Lazy <Thing>(() => this.srdl)); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); this.parameterType = new ParameterTypeComponent(); }
public void MappingRulesTestFixture_TransformOneSinglePart() { STEP3D_Part part = new STEP3D_Part { stepId = 1, type = "PD", name = "Spider1", representation_type = "Shape_Representation" }; STEP3D_PartRelation relation = new STEP3D_PartRelation { id = "Spider1:1", related_id = 1, relating_id = 2, stepId = 211, type = "NUAO" }; Step3DRowViewModel stepModel = new Step3DRowViewModel(part, relation, "step_assembly"); stepModel.UpdateMappingStatus(); List <Step3DRowViewModel> inputValues = new List <Step3DRowViewModel>(); inputValues.Add(stepModel); Step3DPartToElementDefinitionRule translator = new Step3DPartToElementDefinitionRule(); List <ElementBase> outputList; (_, outputList) = translator.Transform(inputValues); var elements = outputList.OfType <ElementDefinition>().ToList(); var parameter = elements.Last().Parameter.First(); var values = parameter.ValueSet.Last(); // We check if the parameter type is correct Assert.IsTrue(parameter.ParameterType is CompoundParameterType); // We expect the user friendlyname to denote a step_geo parameter Assert.IsTrue(parameter.UserFriendlyName.Equals(".step_geo")); CompoundParameterType compound = (CompoundParameterType)parameter.ParameterType; var numberofvalues = compound.NumberOfValues; // We check the number of values Assert.IsTrue(numberofvalues == 6); // we check the values Assert.IsTrue(values.Computed[NAME].Equals("Spider1")); Assert.IsTrue(values.Computed[ID].Equals("1")); Assert.IsTrue(values.Computed[REPRESENTATION_TYPE].Equals("Shape_Representation")); Assert.IsTrue(values.Computed[ASSEMBLY_LABEL].Equals("Spider1:1")); Assert.IsTrue(values.Computed[ASSEMBLY_ID].Equals("211")); Assert.IsTrue(values.Computed[SOURCE].Equals("")); }
public void VerifyCreateParameterOverride() { var browser = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, this.panelNavigationService.Object, null, null, null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.elementDef.Owner, ElementDefinition = this.elementDef, Container = this.elementDef }; var usageRow = new ElementUsageRowViewModel(elementUsage, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var qk = new SimpleQuantityKind(); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.elementDef, ParameterType = qk, Owner = this.elementDef.Owner }; var parameterRow = new ParameterRowViewModel(parameter, this.session.Object, usageRow, false); Assert.IsFalse(browser.CreateOverrideCommand.CanExecute(null)); browser.SelectedThing = parameterRow; Assert.IsTrue(browser.CreateOverrideCommand.CanExecute(null)); browser.CreateOverrideCommand.Execute(parameter); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); browser.SelectedThing = null; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once); var paramtType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); paramtType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri), Scale = null }); parameter.ParameterType = paramtType; var elementDefRow = new ElementDefinitionRowViewModel(this.elementDef, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, elementDefRow, false); browser.SelectedThing = parameterValueBaseRow; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter, Owner = this.elementDef.Owner }; parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameterOverride, 0, this.session.Object, null, null, usageRow, false); browser.SelectedThing = parameterValueBaseRow; browser.CreateOverrideCommand.Execute(null); }
public void VerifyThatIfContainerRowIsNullArgumentNullExceptionIsThrown() { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri); compoundParameterType.Component.Add(component1); parameter.ParameterType = compoundParameterType; Assert.Throws <ArgumentNullException>(() => new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, null)); }
public void SetUp() { this.parameterTypeComponentRuleChecker = new ParameterTypeComponentRuleChecker(); this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(); this.compoundParameterType = new CompoundParameterType { Iid = Guid.Parse("f3d7df0f-a82b-4fa6-a4b3-9978f55c7e4e") }; this.parameterTypeComponent = new ParameterTypeComponent(); this.siteReferenceDataLibrary.ParameterType.Add(this.compoundParameterType); this.compoundParameterType.Component.Add(this.parameterTypeComponent); }
public void VerifyThatIfComponentIndexIsLargerThatCompoundComponentCountExceptionIsThrown() { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri); var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri); compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); parameter.ParameterType = compoundParameterType; Assert.Throws <IndexOutOfRangeException>(() => new ParameterComponentValueRowViewModel(parameter, 2, this.session.Object, null, null, null)); }
public void Verify_that_when_a_referenced_CompoundParameterType_is_finalized_no_result_is_returned() { var compoundParameterType = new CompoundParameterType { Iid = Guid.Parse("693b074c-426c-47f3-87ab-b2b2dad71525"), ShortName = "MATRIX", IsFinalized = true }; this.parameter.ParameterType = compoundParameterType; var results = this.parameterBaseRuleChecker.ChecksWhetherAReferencedCompoundParameterTypeIsFinalizedOrNot(this.parameter); Assert.That(results, Is.Empty); }
public void Verify_that_when_a_referenced_CompoundParameterType_is_not_finalized_a_result_is_returned() { var compoundParameterType = new CompoundParameterType { Iid = Guid.Parse("693b074c-426c-47f3-87ab-b2b2dad71525"), ShortName = "MATRIX", IsFinalized = false }; this.parameter.ParameterType = compoundParameterType; var result = this.parameterBaseRuleChecker.ChecksWhetherAReferencedCompoundParameterTypeIsFinalizedOrNot(this.parameter).Single(); Assert.That(result.Id, Is.EqualTo("MA-0520")); Assert.That(result.Description, Is.EqualTo("The referenced CompoundParameterType 693b074c-426c-47f3-87ab-b2b2dad71525:MATRIX of Parameter.ParameterType is not finalized")); Assert.That(result.Thing, Is.EqualTo(parameter)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Warning)); }
public void VerifyThatTheIndexOfAComponentReturnsTheExpectedResult() { var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); var component0 = new ParameterTypeComponent(Guid.NewGuid(), null, null); var component1 = new ParameterTypeComponent(Guid.NewGuid(), null, null); var component2 = new ParameterTypeComponent(Guid.NewGuid(), null, null); var componentnocontainer = new ParameterTypeComponent(Guid.NewGuid(), null, null); compoundParameterType.Component.Add(component0); compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); Assert.AreEqual(0, component0.Index); Assert.AreEqual(1, component1.Index); Assert.AreEqual(2, component2.Index); Assert.AreEqual(-1, componentnocontainer.Index); }
public void VerifyThatParameterOverrideValueSetQueryParameterTypeAndScaleReturnsExpectedResult() { var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null); var ratioScale = new RatioScale(Guid.NewGuid(), null, null); var parameter = new Parameter(Guid.NewGuid(), null, null) { ParameterType = simpleQuantityKind, Scale = ratioScale }; var paramterValueSet = new ParameterValueSet(Guid.NewGuid(), null, null); parameter.ValueSet.Add(paramterValueSet); var parameterOverride = new ParameterOverride(Guid.NewGuid(), null, null); parameterOverride.Parameter = parameter; var parameterOverrideValueSet = new ParameterOverrideValueSet(Guid.NewGuid(), null, null); parameterOverride.ValueSet.Add(parameterOverrideValueSet); ParameterType parameterType; MeasurementScale measurementScale; ParameterSheetUtilities.QueryParameterTypeAndScale(parameterOverrideValueSet, 0, out parameterType, out measurementScale); Assert.AreEqual(simpleQuantityKind, parameterType); Assert.AreEqual(ratioScale, measurementScale); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); var component = new ParameterTypeComponent(Guid.NewGuid(), null, null); compoundParameterType.Component.Add(component); component.ParameterType = simpleQuantityKind; component.Scale = ratioScale; parameter.ParameterType = compoundParameterType; parameter.Scale = null; ParameterSheetUtilities.QueryParameterTypeAndScale(parameterOverrideValueSet, 0, out parameterType, out measurementScale); Assert.AreEqual(simpleQuantityKind, parameterType); Assert.AreEqual(ratioScale, measurementScale); }
/// <summary> /// Recursive function that computes the number of values for a <see cref="CompoundParameterType" /> /// </summary> /// <param name="compoundParameterType"> /// The <see cref="CompoundParameterType" /> for which the number of values needs to be computed /// </param> /// <returns> /// an integer representing the number of values /// </returns> private int ComputeNumberOfValuesForCompoundParamterType(CompoundParameterType compoundParameterType) { var result = 0; if (compoundParameterType.Component.Count == 0) { Logger.Warn("The CompoundParameterType with Iid {0} does not contain any ParameterTypeComponents", compoundParameterType.Iid); return(0); } foreach (var parameterTypeComponentKeyVaulePair in compoundParameterType.Component) { var parameterTypeComponentIid = Guid.Parse(parameterTypeComponentKeyVaulePair.V.ToString()); ParameterTypeComponent parameterTypeComponent; if (!this.parameterTypeComponentCache.TryGetValue(parameterTypeComponentIid, out parameterTypeComponent)) { var exceptionMessage = $"The ParameterTypeComponent with Iid {parameterTypeComponentIid} could not be found in the DefaultValueArrayFactory cache. A Default ValueArray could not be created"; Logger.Error(exceptionMessage); throw new KeyNotFoundException(exceptionMessage); } ParameterType parameterType; if (!this.parameterTypeCache.TryGetValue(parameterTypeComponent.ParameterType, out parameterType)) { var exceptionMessage = $"The ParameterType {parameterTypeComponent.ParameterType} of the ParameterTypeComponent {parameterTypeComponent.Iid} could not be found in the DefaultValueArrayFactory cache. A Default ValueArray could not be created"; Logger.Error(exceptionMessage); throw new KeyNotFoundException(exceptionMessage); } if (parameterType is ScalarParameterType) { result++; } else { result += this.ComputeNumberOfValuesForCompoundParamterType(parameterType as CompoundParameterType); } } return(result); }
public void SetUp() { var scalarParameterType = new SimpleQuantityKind() { ShortName = "l", Name = "length" }; var compoundParameterType = new CompoundParameterType() { ShortName = "coord", Name = "cartesian coordinate" }; var component = new ParameterTypeComponent() { ShortName = "x" }; component.ParameterType = scalarParameterType; compoundParameterType.Component.Add(component); this.elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null) { ShortName = "Sat" }; this.elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null) { ShortName = "Bat" }; this.elementUsage = new ElementUsage(Guid.NewGuid(), null, null) { ShortName = "battery_1", ElementDefinition = this.elementDefinition2 }; this.elementDefinition1.ContainedElement.Add(this.elementUsage); this.scalarParameter = new Parameter { ParameterType = scalarParameterType }; var scalarParameterValueSet = new ParameterValueSet(); this.scalarParameter.ValueSet.Add(scalarParameterValueSet); this.elementDefinition2.Parameter.Add(this.scalarParameter); }
public void TestComparer2() { var type1 = new CompoundParameterType { Name = "C" }; var type2 = new BooleanParameterType { Name = "a" }; var para1 = new Parameter { ParameterType = type1 }; var para2 = new Parameter { ParameterType = type2 }; var comparer = new ParameterBaseComparer(); Assert.AreEqual(2, comparer.Compare(para1, para2)); }
public void Verify_that_Validate_poco_returns_errors_when_size_of_valuearray_is_incorrect() { var component_1 = new ParameterTypeComponent(Guid.NewGuid(), null, null); component_1.ParameterType = this.booleanParameterType; var component_2 = new ParameterTypeComponent(Guid.NewGuid(), null, null); component_2.ParameterType = this.booleanParameterType; var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); compoundParameterType.Component.Add(component_1); compoundParameterType.Component.Add(component_2); var parameter = new Parameter(Guid.NewGuid(), null, null) { ParameterType = compoundParameterType }; var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), null, null); var parameterSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), null, null); parameterSubscriptionValueSet.Manual = new ValueArray <string>(new List <string> { "true", "false" }); parameterSubscriptionValueSet.SubscribedValueSet = new ParameterValueSet(Guid.NewGuid(), null, null); parameterSubscription.ValueSet.Add(parameterSubscriptionValueSet); parameter.ParameterSubscription.Add(parameterSubscription); parameterSubscriptionValueSet.ValidatePoco(); var errors = parameterSubscriptionValueSet.ValidationErrors; Assert.AreEqual(2, errors.Count()); }
/// <summary> /// Serialize the <see cref="CompoundParameterType"/> /// </summary> /// <param name="compoundParameterType">The <see cref="CompoundParameterType"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(CompoundParameterType compoundParameterType) { var jsonObject = new JObject(); jsonObject.Add("alias", this.PropertySerializerMap["alias"](compoundParameterType.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("category", this.PropertySerializerMap["category"](compoundParameterType.Category.OrderBy(x => x, this.guidComparer))); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), compoundParameterType.ClassKind))); jsonObject.Add("component", this.PropertySerializerMap["component"](compoundParameterType.Component.OrderBy(x => x, this.orderedItemComparer))); jsonObject.Add("definition", this.PropertySerializerMap["definition"](compoundParameterType.Definition.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](compoundParameterType.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](compoundParameterType.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](compoundParameterType.HyperLink.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](compoundParameterType.Iid)); jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](compoundParameterType.IsDeprecated)); jsonObject.Add("isFinalized", this.PropertySerializerMap["isFinalized"](compoundParameterType.IsFinalized)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](compoundParameterType.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](compoundParameterType.Name)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](compoundParameterType.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](compoundParameterType.ShortName)); jsonObject.Add("symbol", this.PropertySerializerMap["symbol"](compoundParameterType.Symbol)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](compoundParameterType.ThingPreference)); return(jsonObject); }
public void VerifyThatValidatePropertyWorks() { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); parameter.Owner = this.activeDomain; var boolPt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); parameter.ParameterType = compoundParameterType; this.elementDefinition.Parameter.Add(parameter); var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); parameterSubscription.Owner = this.otherDomain; parameter.ParameterSubscription.Add(parameterSubscription); var parameterSubscriptionRowViewModel = new ParameterSubscriptionRowViewModel(parameterSubscription, this.session.Object, null, false); var component1row = (ParameterComponentValueRowViewModel)parameterSubscriptionRowViewModel.ContainedRows.First(); Assert.That(component1row.ValidateProperty("Manual", "123"), Is.Not.Null.Or.Empty); Assert.That(component1row.ValidateProperty("Reference", "123"), Is.Not.Null.Or.Empty); Assert.That(component1row.ValidateProperty("Manual", false), Is.Null.Or.Empty); Assert.That(component1row.ValidateProperty("Reference", null), Is.Null.Or.Empty); }
public void VerifyThatTheSwitchIsUpdatedWhenContainerRowIsAParameterSubscriptionRowViewModel() { var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); parameter.Owner = this.activeDomain; var boolPt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri); var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); var component1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; var component2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = boolPt }; compoundParameterType.Component.Add(component1); compoundParameterType.Component.Add(component2); parameter.ParameterType = compoundParameterType; this.elementDefinition.Parameter.Add(parameter); var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); parameterSubscription.Owner = this.otherDomain; parameter.ParameterSubscription.Add(parameterSubscription); var parameterSubscriptionRowViewModel = new ParameterSubscriptionRowViewModel(parameterSubscription, this.session.Object, null); var component1row = (ParameterComponentValueRowViewModel)parameterSubscriptionRowViewModel.ContainedRows.First(); var component2row = (ParameterComponentValueRowViewModel)parameterSubscriptionRowViewModel.ContainedRows.Last(); component1row.Switch = ParameterSwitchKind.COMPUTED; Assert.AreEqual(ParameterSwitchKind.COMPUTED, component2row.Switch); }
public void VerifyThatNumberOfValuesIsCorrect() { var compound = new CompoundParameterType(); var compound2 = new CompoundParameterType(); var scalar = new EnumerationParameterType(); var scalarc1 = new ParameterTypeComponent() { ParameterType = scalar }; compound2.Component.Add(scalarc1); var compound2Component = new ParameterTypeComponent() { ParameterType = compound2 }; compound.Component.Add(compound2Component); compound.Component.Add(scalarc1); Assert.AreEqual(2, compound.NumberOfValues); }
private void PopulateParameterTypes() { this.parameterTypes = new List <ParameterType>(); this.parameterTypeComponents = new List <ParameterTypeComponent>(); this.massIid = Guid.NewGuid(); this.lengthIid = Guid.NewGuid(); this.vectorIid = Guid.NewGuid(); this.xIid = Guid.NewGuid(); this.yIid = Guid.NewGuid(); this.zIid = Guid.NewGuid(); this.jaggedArrayIid = Guid.NewGuid(); this.jaggedComponentOneIid = Guid.NewGuid(); this.jaggedComponentTwoIid = Guid.NewGuid(); var mass = new SimpleQuantityKind(this.massIid, 0); var length = new SimpleQuantityKind(this.lengthIid, 0); // create a vector var x = new ParameterTypeComponent(this.xIid, 0) { ParameterType = length.Iid }; var y = new ParameterTypeComponent(this.yIid, 0) { ParameterType = length.Iid }; var z = new ParameterTypeComponent(this.zIid, 0) { ParameterType = length.Iid }; var orderedItemX = new OrderedItem { K = 1, V = x.Iid }; var orderedItemY = new OrderedItem { K = 2, V = y.Iid }; var orderedItemZ = new OrderedItem { K = 3, V = z.Iid }; var vector = new CDP4Common.DTO.ArrayParameterType(this.vectorIid, 0); vector.Component.Add(orderedItemX); vector.Component.Add(orderedItemY); vector.Component.Add(orderedItemZ); this.parameterTypes.Add(mass); this.parameterTypes.Add(length); this.parameterTypes.Add(vector); this.parameterTypeComponents.Add(x); this.parameterTypeComponents.Add(y); this.parameterTypeComponents.Add(z); // create a jagged array var jaggedComponentOne = new ParameterTypeComponent(this.jaggedComponentOneIid, 0) { ParameterType = length.Iid }; var jaggedComponentTwo = new ParameterTypeComponent(this.jaggedComponentTwoIid, 0) { ParameterType = vector.Iid }; var jaggedOrderedItemOne = new OrderedItem { K = 1, V = jaggedComponentOne.Iid }; var jaggedOrderedItemTwo = new OrderedItem { K = 1, V = jaggedComponentTwo.Iid }; var jaggedArray = new CDP4Common.DTO.CompoundParameterType(this.jaggedArrayIid, 0); jaggedArray.Component.Add(jaggedOrderedItemOne); jaggedArray.Component.Add(jaggedOrderedItemTwo); this.parameterTypes.Add(jaggedArray); this.parameterTypeComponents.Add(jaggedComponentOne); this.parameterTypeComponents.Add(jaggedComponentTwo); // incomplete compound this.incompleteCoundParameterTypeIid = Guid.NewGuid(); var incompleteCoundParameterType = new CompoundParameterType(this.incompleteCoundParameterTypeIid, 0); this.parameterTypes.Add(incompleteCoundParameterType); // incorrect component referenced compound this.invalidReferencedCompoundParameterTypeIid = Guid.NewGuid(); var invalidReferencedCompoundParameterType = new CompoundParameterType(this.invalidReferencedCompoundParameterTypeIid, 0); var invalidReferencedCompoundParameterTypeOrderedItemOne = new OrderedItem { K = 1, V = Guid.NewGuid() }; invalidReferencedCompoundParameterType.Component.Add(invalidReferencedCompoundParameterTypeOrderedItemOne); this.parameterTypes.Add(invalidReferencedCompoundParameterType); // incorrect referenced parametertype from component this.invalidReferencedParameterTypeFromComponentIid = Guid.NewGuid(); var invalidReferencedParameterTypeFromComponent = new CompoundParameterType(this.invalidReferencedParameterTypeFromComponentIid, 0); var invalidComponent = new ParameterTypeComponent(Guid.NewGuid(), 0) { ParameterType = Guid.NewGuid() }; var invalidComponentItemOne = new OrderedItem { K = 1, V = invalidComponent.Iid }; invalidReferencedParameterTypeFromComponent.Component.Add(invalidComponentItemOne); this.parameterTypes.Add(invalidReferencedParameterTypeFromComponent); this.parameterTypeComponents.Add(invalidComponent); }
public void Setup() { this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.thingDialognavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.stateList = new ActualFiniteStateList(Guid.NewGuid(), null, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), null, this.uri) { Name = "state1" }; this.state2 = new PossibleFiniteState(Guid.NewGuid(), null, this.uri) { Name = "state2" }; this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.actualState1 = new ActualFiniteState(Guid.NewGuid(), null, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }; this.actualState2 = new ActualFiniteState(Guid.NewGuid(), null, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.MANDATORY }; this.stateList.ActualState.Add(this.actualState1); this.stateList.ActualState.Add(this.actualState2); this.stateList.PossibleFiniteStateList.Add(this.posStateList); this.option1 = new Option(Guid.NewGuid(), null, this.uri) { Name = "option1" }; this.option2 = new Option(Guid.NewGuid(), null, this.uri) { Name = "option2" }; this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri) { Name = "PTName", ShortName = "PTShortName" }; this.enum1 = new EnumerationValueDefinition(Guid.NewGuid(), null, this.uri) { Name = "enum1" }; this.enum2 = new EnumerationValueDefinition(Guid.NewGuid(), null, this.uri) { Name = "enum2" }; this.enumPt = new EnumerationParameterType(Guid.NewGuid(), null, this.uri); this.enumPt.ValueDefinition.Add(this.enum1); this.enumPt.ValueDefinition.Add(this.enum2); this.cptType = new CompoundParameterType(Guid.NewGuid(), null, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType, ShortName = "c1" }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.enumPt, ShortName = "c2" }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri) { Name = "active", ShortName = "active" }; this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri) { Name = "other", ShortName = "other" }; this.parameter = new Parameter(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain, ParameterType = this.qqParamType }; this.cptParameter = new Parameter(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain, ParameterType = this.cptType, IsOptionDependent = true, StateDependence = this.stateList }; this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.First())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.Last())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.First())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.Last())); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain }; this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), null, this.uri); this.elementUsage1 = new ElementUsage(Guid.NewGuid(), null, this.uri) { ElementDefinition = this.elementDefinitionForUsage1 }; this.elementDefinition.ContainedElement.Add(this.elementUsage1); this.elementDefinitionForUsage1.Parameter.Add(this.parameter); this.elementDefinitionForUsage1.Parameter.Add(this.cptParameter); this.iteration = new Iteration(Guid.NewGuid(), null, this.uri); this.iteration.Element.Add(this.elementDefinition); this.iteration.Element.Add(this.elementDefinitionForUsage1); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.model = new EngineeringModel(Guid.NewGuid(), null, this.uri); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), null, this.uri) { GivenName = "test", Surname = "test" }; this.participant = new Participant(Guid.NewGuid(), null, this.uri) { Person = this.person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(this.person); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); this.modelsetup.Participant.Add(this.participant); this.model.EngineeringModelSetup = this.modelsetup; this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }
/// <summary> /// Initializes a new instance of the <see cref="CompoundParameterTypeDialogViewModel"/> class. /// </summary> /// <param name="compoundParameterType">The <see cref="CompoundParameterType"/></param> /// <param name="transaction">The <see cref="ThingTransaction"/> that contains the log of recorded changes</param> /// <param name="session">The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated</param> /// <param name="isRoot">Assert if this <see cref="BooleanParameterTypeDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/></param> /// <param name="dialogKind">The kind of operation this <see cref="BooleanParameterTypeDialogViewModel"/> performs</param> /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/></param> /// <param name="container">The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog</param> /// <param name="chainOfContainers">The optional chain of containers that contains the <paramref name="container"/> argument</param> /// <exception cref="ArgumentException"> /// The container must be of type <see cref="ReferenceDataLibrary"/>. /// </exception> public CompoundParameterTypeDialogViewModel(CompoundParameterType compoundParameterType, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(compoundParameterType, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { }