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")); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterTypeComponentRowViewModel"/> class /// </summary> /// <param name="component">The <see cref="ParameterTypeComponent"/> represented</param> /// <param name="session">The <see cref="ISession"/></param> /// <param name="containerViewModel">The viewmodel that contains this row</param> public ParameterTypeComponentRowViewModel(ParameterTypeComponent component, ISession session, CompoundParameterTypeDialogViewModel containerViewModel) : base(component, session, containerViewModel) { this.PossibleScale = new ReactiveList <MeasurementScale>(); this.FilteringOptions = new Dictionary <string, Type>(); this.FilteringOptions.Add(string.Empty, null); foreach (var type in TypeResolver.GetDerivedTypes(typeof(ParameterType), typeof(ParameterType).Assembly).Where(x => !x.IsAbstract)) { this.FilteringOptions.Add(type.Name, type); } this.possibleParameterTypes = containerViewModel.PossibleParameterType; this.PossibleParameterType = new ReactiveList <ParameterType>(); this.PossibleParameterType.ChangeTrackingEnabled = true; this.PossibleParameterType.AddRange(this.possibleParameterTypes); this.WhenAnyValue(x => x.ParameterType).Subscribe(_ => { this.PopulatePossibleScale(); containerViewModel.UpdateOkCanExecuteStatus(); }); this.IsReadOnly = containerViewModel.IsReadOnly; this.WhenAnyValue(x => x.ShortName).Subscribe(x => { this.ErrorMsg = (string.IsNullOrWhiteSpace(this.ShortName)) ? "The short-name may not be null." : string.Empty; containerViewModel.UpdateOkCanExecuteStatus(); }); this.SelectedFilter = null; this.WhenAnyValue(x => x.SelectedFilter).Subscribe(_ => this.FilterPossibleParameterType()); }
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()); }
/// <summary> /// Populate the components /// </summary> protected override void PopulateComponent() { this.Component.Clear(); if (this.NumberOfComponents != 0) { this.ComputeComponentCoordinateDenominator(); } for (var i = 0; i < this.NumberOfComponents; i++) { ParameterTypeComponentRowViewModel row; var coordinates = this.ComputeComponentCoordinates(i + 1); if (this.Thing.Component.Count > i) { var component = this.Thing.Component[i]; row = new ParameterTypeComponentRowViewModel(component, this.Session, this); } else { // create new ParameterTypeComponent var component = new ParameterTypeComponent(); row = new ParameterTypeComponentRowViewModel(component, this.Session, this); row.ShortName = coordinates; } row.Coordinates = coordinates; this.Component.Add(row); } }
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); }
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 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()); }
/// <summary> /// Execute the <see cref="CreateComponentCommand"/> /// </summary> protected void ExecuteCreateComponent() { var component = new ParameterTypeComponent(); var row = new ParameterTypeComponentRowViewModel(component, this.Session, this); this.Component.Add(row); }
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 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)); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterTypeComponentRowViewModel"/> class /// </summary> /// <param name="component">The <see cref="ParameterTypeComponent"/> represented</param> /// <param name="session">The <see cref="ISession"/></param> /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param> public ParameterTypeComponentRowViewModel(ParameterTypeComponent component, ISession session, IViewModelBase <Thing> containerViewModel) : base(component, session, containerViewModel) { this.Name = this.Thing.ShortName; this.IsPublishable = false; var parameterOrOverrideBaseRowViewModel = containerViewModel as ParameterOrOverrideBaseRowViewModel; if (parameterOrOverrideBaseRowViewModel != null) { this.OwnerShortName = parameterOrOverrideBaseRowViewModel.OwnerShortName; } }
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)); }
/// <summary> /// Serialize the <see cref="ParameterTypeComponent"/> /// </summary> /// <param name="parameterTypeComponent">The <see cref="ParameterTypeComponent"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(ParameterTypeComponent parameterTypeComponent) { var jsonObject = new JObject(); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), parameterTypeComponent.ClassKind))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](parameterTypeComponent.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](parameterTypeComponent.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](parameterTypeComponent.Iid)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](parameterTypeComponent.ModifiedOn)); jsonObject.Add("parameterType", this.PropertySerializerMap["parameterType"](parameterTypeComponent.ParameterType)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](parameterTypeComponent.RevisionNumber)); jsonObject.Add("scale", this.PropertySerializerMap["scale"](parameterTypeComponent.Scale)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](parameterTypeComponent.ShortName)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](parameterTypeComponent.ThingPreference)); return(jsonObject); }
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); }
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 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()); }
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); }
public void Setup() { this.securityContext = new Mock <ISecurityContext>(); this.optionService = new Mock <IOptionService>(); this.actualFiniteStateListService = new Mock <IActualFiniteStateListService>(); this.parameterService = new Mock <ICompoundParameterTypeService>(); this.valueSetService = new Mock <IParameterValueSetService>(); this.iterationService = new Mock <IIterationService>(); this.parameterOverrideValueSetService = new Mock <IParameterOverrideValueSetService>(); this.parameterSubscriptionValueSetService = new Mock <IParameterSubscriptionValueSetService>(); this.parameterSubscriptionService = new Mock <IParameterSubscriptionService>(); this.parameterOverrideService = new Mock <IParameterOverrideService>(); this.parameterTypeComponentService = new Mock <IParameterTypeComponentService>(); this.parameterTypeService = new Mock <IParameterTypeService>(); this.elementUsageService = new Mock <IElementUsageService>(); this.defaultValueArrayFactory = new Mock <IDefaultValueArrayFactory>(); this.npgsqlTransaction = null; this.iteration = new Iteration(Guid.NewGuid(), 1); this.option1 = new Option(Guid.NewGuid(), 1); this.option2 = new Option(Guid.NewGuid(), 1); this.iteration.Option.Add(new OrderedItem { K = 1, V = this.option1.Iid }); this.iteration.Option.Add(new OrderedItem { K = 2, V = this.option2.Iid }); this.actualList = new ActualFiniteStateList(Guid.NewGuid(), 1); this.actualState1 = new ActualFiniteState(Guid.NewGuid(), 1); this.actualState2 = new ActualFiniteState(Guid.NewGuid(), 1); this.actualList.ActualState.Add(this.actualState1.Iid); this.actualList.ActualState.Add(this.actualState2.Iid); this.parameter = new Parameter(Guid.NewGuid(), 1); this.cptParameterType = new CompoundParameterType(Guid.NewGuid(), 1); this.boolPt = new BooleanParameterType(Guid.NewGuid(), 1); this.cpt1 = new ParameterTypeComponent(Guid.NewGuid(), 1) { ParameterType = this.boolPt.Iid }; this.cpt2 = new ParameterTypeComponent(Guid.NewGuid(), 1) { ParameterType = this.boolPt.Iid }; this.cptParameterType.Component.Add(new OrderedItem { K = 1, V = this.cpt1.Iid.ToString() }); this.cptParameterType.Component.Add(new OrderedItem { K = 2, V = this.cpt2.Iid.ToString() }); this.sideEffect = new ParameterSideEffect { IterationService = this.iterationService.Object, ActualFiniteStateListService = this.actualFiniteStateListService.Object, ParameterValueSetService = this.valueSetService.Object, ParameterOverrideValueSetService = this.parameterOverrideValueSetService.Object, ParameterSubscriptionValueSetService = this.parameterSubscriptionValueSetService.Object, ParameterOverrideService = this.parameterOverrideService.Object, ParameterSubscriptionService = this.parameterSubscriptionService.Object, ParameterTypeService = this.parameterTypeService.Object, ElementUsageService = this.elementUsageService.Object, ParameterTypeComponentService = this.parameterTypeComponentService.Object, OptionService = this.optionService.Object, DefaultValueArrayFactory = this.defaultValueArrayFactory.Object, ParameterValueSetFactory = new ParameterValueSetFactory(), ParameterOverrideValueSetFactory = new ParameterOverrideValueSetFactory(), ParameterSubscriptionValueSetFactory = new ParameterSubscriptionValueSetFactory() }; // prepare mock data this.elementDefinition = new ElementDefinition(Guid.NewGuid(), 1); this.elementDefinition.Parameter.Add(this.parameter.Iid); this.parameterOverride = new ParameterOverride(Guid.NewGuid(), 1) { Parameter = this.parameter.Iid }; this.elementUsage = new ElementUsage(Guid.NewGuid(), 1) { ElementDefinition = this.elementDefinition.Iid, ParameterOverride = { this.parameterOverride.Iid } }; this.parameterService.Setup(x => x.Get(It.IsAny <NpgsqlTransaction>(), "SiteDirectory", It.Is <IEnumerable <Guid> >(y => y.Contains(this.cptParameterType.Iid)), this.securityContext.Object)) .Returns(new List <Thing> { this.cptParameterType }); this.iterationService.Setup(x => x.GetShallow(null, "partition", null, this.securityContext.Object)) .Returns(new List <Thing> { this.iteration }); this.actualFiniteStateListService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), "partition", It.Is <IEnumerable <Guid> >(y => y.Contains(this.actualList.Iid)), this.securityContext.Object)) .Returns(new List <Thing> { this.actualList }); this.parameterTypeService.Setup(x => x.GetShallow(this.npgsqlTransaction, "SiteDirectory", null, this.securityContext.Object)) .Returns(new List <Thing> { this.boolPt, this.cptParameterType }); this.parameterTypeService.Setup(x => x.GetShallow(this.npgsqlTransaction, "SiteDirectory", new List <Guid> { this.existingNotQuantityKindParameterTypeGuid }, this.securityContext.Object)) .Returns(new List <Thing> { new BooleanParameterType(this.existingNotQuantityKindParameterTypeGuid, 1) }); this.parameterTypeService.Setup(x => x.GetShallow(this.npgsqlTransaction, "SiteDirectory", new List <Guid> { this.existingQuantityKindParameterTypeGuid }, this.securityContext.Object)) .Returns(new List <Thing> { new SimpleQuantityKind(this.existingQuantityKindParameterTypeGuid, 1) }); this.parameterTypeService.Setup(x => x.GetShallow(this.npgsqlTransaction, "SiteDirectory", new List <Guid> { this.notExistingParameterTypeGuid }, this.securityContext.Object)) .Returns(new List <Thing>()); this.parameterTypeComponentService.Setup(x => x.GetShallow(this.npgsqlTransaction, "SiteDirectory", null, this.securityContext.Object)) .Returns(new List <Thing> { this.cpt1, this.cpt2 }); this.parameterOverrideService.Setup(x => x.GetShallow(this.npgsqlTransaction, "partition", null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameterOverride }); this.elementUsageService.Setup(x => x.GetShallow(this.npgsqlTransaction, "partition", null, this.securityContext.Object)) .Returns(new List <Thing> { this.elementUsage }); this.scalarDefaultValueArray = new ValueArray <string>(new List <string>() { "-" }); this.compoundDefaultValueArray = new ValueArray <string>(new List <string>() { "-", "-" }); this.defaultValueArrayFactory.Setup(x => x.CreateDefaultValueArray(this.cptParameterType.Iid)) .Returns(this.compoundDefaultValueArray); this.defaultValueArrayFactory.Setup(x => x.CreateDefaultValueArray(this.boolPt.Iid)) .Returns(this.scalarDefaultValueArray); }
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.npgsqlTransaction = null; this.securityContext = new Mock <ISecurityContext>(); // There is a chain aptA -> ptcA -> aptB -> ptcB -> bptD this.booleanParameterTypeD = new BooleanParameterType { Iid = Guid.NewGuid() }; this.parameterTypeComponentD = new ParameterTypeComponent { Iid = Guid.NewGuid(), ParameterType = this.booleanParameterTypeD.Iid }; this.parameterTypeComponentB = new ParameterTypeComponent { Iid = Guid.NewGuid(), ParameterType = this.booleanParameterTypeD.Iid }; var parameterTypeComponentForB = new OrderedItem { K = 1, V = this.parameterTypeComponentB.Iid }; var parameterTypeComponentsForB = new List <OrderedItem> { parameterTypeComponentForB }; this.arrayParameterTypeB = new ArrayParameterType { Iid = Guid.NewGuid(), Component = parameterTypeComponentsForB }; this.parameterTypeComponentA = new ParameterTypeComponent { Iid = Guid.NewGuid(), ParameterType = this.arrayParameterTypeB.Iid }; var parameterTypeComponentForA = new OrderedItem { K = 1, V = this.parameterTypeComponentA.Iid }; var parameterTypeComponentsForA = new List <OrderedItem> { parameterTypeComponentForA }; this.arrayParameterTypeA = new ArrayParameterType { Iid = Guid.NewGuid(), Component = parameterTypeComponentsForA }; this.parameterTypeComponentC = new ParameterTypeComponent { Iid = Guid.NewGuid(), ParameterType = this.arrayParameterTypeA.Iid }; // There is a chain librayA -> LibraryB this.referenceDataLibraryB = new SiteReferenceDataLibrary { Iid = Guid.NewGuid(), ParameterType = { this.booleanParameterTypeD.Iid } }; this.referenceDataLibraryA = new ModelReferenceDataLibrary { Iid = Guid.NewGuid(), ParameterType = { this.arrayParameterTypeA .Iid, this.arrayParameterTypeB .Iid }, RequiredRdl = this.referenceDataLibraryB.Iid }; this.siteReferenceDataLibraryService = new Mock <ISiteReferenceDataLibraryService>(); this.siteReferenceDataLibraryService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), null, It.IsAny <ISecurityContext>())) .Returns(new List <ReferenceDataLibrary> { this.referenceDataLibraryB }); this.arrayParameterTypeService = new Mock <IArrayParameterTypeService>(); this.arrayParameterTypeService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.booleanParameterTypeD.Iid, this.arrayParameterTypeA.Iid, this.arrayParameterTypeB.Iid }, It.IsAny <ISecurityContext>())).Returns( new List <CompoundParameterType> { this.arrayParameterTypeA, this.arrayParameterTypeB }); this.compoundParameterTypeService = new Mock <ICompoundParameterTypeService>(); this.compoundParameterTypeService.Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.booleanParameterTypeD.Iid, this.arrayParameterTypeA.Iid, this.arrayParameterTypeB.Iid }, It.IsAny <ISecurityContext>())).Returns(new List <ArrayParameterType>()); this.parameterTypeComponentService = new Mock <IParameterTypeComponentService>(); this.parameterTypeComponentService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.parameterTypeComponentA.Iid }, It.IsAny <ISecurityContext>())).Returns( new List <ParameterTypeComponent> { this.parameterTypeComponentA }); this.parameterTypeComponentService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.parameterTypeComponentB.Iid }, It.IsAny <ISecurityContext>())).Returns( new List <ParameterTypeComponent> { this.parameterTypeComponentB }); this.parameterTypeComponentService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.parameterTypeComponentC.Iid }, It.IsAny <ISecurityContext>())).Returns( new List <ParameterTypeComponent> { this.parameterTypeComponentC }); this.parameterTypeComponentService .Setup( x => x.Get( this.npgsqlTransaction, It.IsAny <string>(), new List <Guid> { this.parameterTypeComponentD.Iid }, It.IsAny <ISecurityContext>())).Returns( new List <ParameterTypeComponent> { this.parameterTypeComponentD }); this.sideEffect = new ArrayParameterTypeSideEffect() { CompoundParameterTypeService = this.compoundParameterTypeService.Object, ArrayParameterTypeService = this.arrayParameterTypeService.Object, ParameterTypeComponentService = this.parameterTypeComponentService.Object, SiteReferenceDataLibraryService = this.siteReferenceDataLibraryService.Object }; }
public void SetUp() { this.domain = new DomainOfExpertise(Guid.NewGuid(), null, null) { Name = "domain", ShortName = "d" }; this.scalarParameterTypeShortname = "m"; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = this.scalarParameterTypeShortname }; this.scalarParameterType = simpleQuantityKind; this.edShortname = "Sat"; this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.domain, ShortName = this.edShortname }; this.scalarParameter = new Parameter(Guid.NewGuid(), null, null) { Owner = this.domain }; this.scalarParameter.ParameterType = this.scalarParameterType; this.elementDefinition.Parameter.Add(this.scalarParameter); this.compoundParameterTypeShortname = "coord"; this.compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); this.compoundParameterType.ShortName = this.compoundParameterTypeShortname; this.component = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = this.scalarParameterType }; this.component.ShortName = this.scalarParameterType.ShortName; this.compoundParameterType.Component.Add(this.component); this.compoundParameter = new Parameter(Guid.NewGuid(), null, null) { Owner = this.domain, ParameterType = this.compoundParameterType }; this.elementDefinition.Parameter.Add(this.compoundParameter); this.iteration = new Iteration(Guid.NewGuid(), null, null); this.option1 = new Option(Guid.NewGuid(), null, null) { Name = "option1", ShortName = "o1" }; this.option2 = new Option(Guid.NewGuid(), null, null) { Name = "option2", ShortName = "o2" }; this.possibleList = new PossibleFiniteStateList(Guid.NewGuid(), null, null) { Name = "possible list", ShortName = "pl" }; this.possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "ps1", ShortName = "ps1" }; this.possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "ps2", ShortName = "ps2" }; this.possibleList.PossibleState.Add(this.possibleState1); this.possibleList.PossibleState.Add(this.possibleState2); this.actualList = new ActualFiniteStateList(Guid.NewGuid(), null, null); this.actualList.PossibleFiniteStateList.Add(this.possibleList); this.actualState1 = new ActualFiniteState(Guid.NewGuid(), null, null); this.actualState1.PossibleState.Add(this.possibleState1); this.actualState2 = new ActualFiniteState(Guid.NewGuid(), null, null); this.actualState2.PossibleState.Add(this.possibleState2); this.actualList.ActualState.Add(this.actualState1); this.actualList.ActualState.Add(this.actualState2); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.iteration.PossibleFiniteStateList.Add(this.possibleList); this.iteration.ActualFiniteStateList.Add(this.actualList); this.iteration.Element.Add(this.elementDefinition); }
public void Setup() { this.uri = new Uri("http://www.rheagroup.com"); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); var testDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); var subscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); var anotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "Other Domain" }; subscription.Owner = anotherDomain; var paramValueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); paramValueSet.Computed = new ValueArray <string>(new[] { "c" }); paramValueSet.Manual = new ValueArray <string>(new[] { "m" }); paramValueSet.Reference = new ValueArray <string>(new[] { "r" }); paramValueSet.ValueSwitch = ParameterSwitchKind.COMPUTED; var testParamType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = testDomain, ParameterType = testParamType }; this.parameter.ParameterSubscription.Add(subscription); this.parameter.ValueSet.Add(paramValueSet); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); elementDefinition.Parameter.Add(this.parameter); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.option1 = new Option(Guid.NewGuid(), this.cache, this.uri) { Name = "opt1", ShortName = "o1" }; this.option2 = new Option(Guid.NewGuid(), this.cache, this.uri) { Name = "opt2", ShortName = "o2" }; this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.iteration.Element.Add(elementDefinition); this.psl = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.ps1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "1", ShortName = "1" }; this.ps2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "2", ShortName = "2" }; this.psl.PossibleState.Add(this.ps1); this.psl.PossibleState.Add(this.ps2); this.asl = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.as1 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.as1.PossibleState.Add(this.ps1); this.as2 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.as2.PossibleState.Add(this.ps2); this.asl.PossibleFiniteStateList.Add(this.psl); this.asl.ActualState.Add(this.as1); this.asl.ActualState.Add(this.as2); this.iteration.ActualFiniteStateList.Add(this.asl); this.iteration.PossibleFiniteStateList.Add(this.psl); var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); modelSetup.ActiveDomain.Add(testDomain); modelSetup.ActiveDomain.Add(anotherDomain); var testPerson = new Person(Guid.NewGuid(), null, null); var testParticipant = new Participant(Guid.NewGuid(), null, null) { Person = testPerson, SelectedDomain = testDomain }; modelSetup.Participant.Add(testParticipant); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = modelSetup }; this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var ratioScale = new RatioScale(Guid.NewGuid(), this.cache, this.uri); this.srdl.Scale.Add(ratioScale); testParamType.PossibleScale.Add(ratioScale); this.srdl.ParameterType.Add(testParamType); var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.model.EngineeringModelSetup.RequiredRdl.Add(mrdl); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.model.Iteration.Add(this.iteration); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); this.session.Setup(x => x.ActivePerson).Returns(testPerson); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.elementDefinitionClone = elementDefinition.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, this.elementDefinitionClone); this.integerScale = new RatioScale(Guid.NewGuid(), this.cache, this.uri) { NumberSet = NumberSetKind.INTEGER_NUMBER_SET, MaximumPermissibleValue = "5", MinimumPermissibleValue = "0" }; this.realScale = new RatioScale(Guid.NewGuid(), this.cache, this.uri) { MaximumPermissibleValue = "50", MinimumPermissibleValue = "0", NumberSet = NumberSetKind.REAL_NUMBER_SET }; this.simpleQt = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); this.simpleQt.PossibleScale.Add(this.integerScale); this.simpleQt.PossibleScale.Add(this.realScale); this.cptPt = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri); this.c1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.simpleQt, Scale = this.integerScale }; this.cptPt.Component.Add(this.c1); this.srdl.Scale.Add(this.integerScale); this.srdl.Scale.Add(this.realScale); this.srdl.ParameterType.Add(this.cptPt); this.srdl.ParameterType.Add(this.simpleQt); 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()); }
public void SetUp() { this.concurentDictionary = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.iteration = new Iteration(Guid.NewGuid(), this.concurentDictionary, this.uri); this.SystemEngineering = new DomainOfExpertise(Guid.NewGuid(), this.concurentDictionary, this.uri) { Name = "System Engineering", ShortName = "SYS" }; this.PowerEngineering = new DomainOfExpertise(Guid.NewGuid(), this.concurentDictionary, this.uri) { Name = "Power Engineering", ShortName = "PWR" }; this.optionA = new Option(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "A", Name = "Option A" }; this.optionB = new Option(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "B", Name = "Option B" }; this.iteration.Option.Add(this.optionA); this.iteration.Option.Add(this.optionB); this.cellCategory = new Category(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "CELLS", Name = "Cells" }; this.satelliteDefinition = new ElementDefinition(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "SAT", Name = "Satellite", Owner = this.SystemEngineering }; this.iteration.Element.Add(this.satelliteDefinition); this.iteration.TopElement = this.satelliteDefinition; this.solarArrayDefinition = new ElementDefinition(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "SA", Name = "Solar Array", Owner = this.PowerEngineering }; this.iteration.Element.Add(this.solarArrayDefinition); this.arrayWingDefinition = new ElementDefinition(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "WING", Name = "Wing", Owner = this.PowerEngineering }; this.iteration.Element.Add(this.arrayWingDefinition); this.solarCellDefinition = new ElementDefinition(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "CELL", Name = "Cell", Owner = this.PowerEngineering, }; this.solarCellDefinition.Category.Add(this.cellCategory); this.iteration.Element.Add(this.solarCellDefinition); var solarArrayUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "SA", Name = "The Solar Array", ElementDefinition = this.solarArrayDefinition, Owner = this.PowerEngineering }; this.satelliteDefinition.ContainedElement.Add(solarArrayUsage); this.wingLeftUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "LW", Name = "Left Wing", ElementDefinition = this.arrayWingDefinition, Owner = this.PowerEngineering }; var wingRightUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "LW", Name = "Left Wing", ElementDefinition = this.arrayWingDefinition, Owner = this.PowerEngineering }; this.solarArrayDefinition.ContainedElement.Add(this.wingLeftUsage); this.solarArrayDefinition.ContainedElement.Add(wingRightUsage); var aSolarCellUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "A", Name = "Cell A", ElementDefinition = solarCellDefinition, Owner = this.PowerEngineering }; var bSolarCellUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "B", Name = "Cell B", ElementDefinition = solarCellDefinition, Owner = this.PowerEngineering }; var cSolarCellUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "C", Name = "Cell C", ElementDefinition = solarCellDefinition, Owner = this.PowerEngineering }; var dSolarCellUsage = new ElementUsage(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "D", Name = "Cell D", ElementDefinition = solarCellDefinition, Owner = this.PowerEngineering }; this.arrayWingDefinition.ContainedElement.Add(aSolarCellUsage); this.arrayWingDefinition.ContainedElement.Add(bSolarCellUsage); this.arrayWingDefinition.ContainedElement.Add(cSolarCellUsage); this.arrayWingDefinition.ContainedElement.Add(dSolarCellUsage); // Create ParameterTypes and Parameters this.mass = new SimpleQuantityKind(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "m", Name = "mass" }; var length = new SimpleQuantityKind(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "l", Name = "length" }; this.cartesianCoordinates = new ArrayParameterType(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "coord", Name = "coordinate" }; var xcoordinate = new ParameterTypeComponent(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "x", ParameterType = length }; var ycoordinate = new ParameterTypeComponent(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "y", ParameterType = length }; var zcoordinate = new ParameterTypeComponent(Guid.NewGuid(), this.concurentDictionary, this.uri) { ShortName = "z", ParameterType = length }; this.cartesianCoordinates.Component.Add(xcoordinate); this.cartesianCoordinates.Component.Add(ycoordinate); this.cartesianCoordinates.Component.Add(zcoordinate); this.satelliteMass = new Parameter(Guid.NewGuid(), this.concurentDictionary, this.uri) { ParameterType = this.mass, Owner = this.SystemEngineering }; var satelliteMassValueset = new ParameterValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.satelliteMass.ValueSet.Add(satelliteMassValueset); this.satelliteDefinition.Parameter.Add(this.satelliteMass); this.solarCellMass = new Parameter(Guid.NewGuid(), this.concurentDictionary, this.uri) { ParameterType = this.mass, Owner = this.PowerEngineering }; var solarCellMassValueset = new ParameterValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.solarCellMass.ValueSet.Add(solarCellMassValueset); this.solarCellDefinition.Parameter.Add(this.solarCellMass); this.solarCellCoordinates = new Parameter(Guid.NewGuid(), this.concurentDictionary, this.uri) { ParameterType = this.cartesianCoordinates, Owner = this.PowerEngineering }; var solarCellCoordinatesValueSet = new ParameterValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri) { Manual = new ValueArray <string>(new List <string> { "x-manual", "y-manual", "z-manual" }), Computed = new ValueArray <string>(new List <string> { "x-computed", "y-computed", "z-computed" }), Formula = new ValueArray <string>(new List <string> { "x-formula", "y-formula", "z-formula" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.solarCellCoordinates.ValueSet.Add(solarCellCoordinatesValueSet); this.solarCellDefinition.Parameter.Add(this.solarCellCoordinates); }
public void VerifyThatParametersAreInRightOrder() { var parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type, Owner = this.domain, Container = this.elementDef }; parameter1.ValueSet.Add(this.valueSet); var cpt = new CompoundParameterType { Name = "B", ShortName = "B" }; var cpt1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type }; var cpt2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type }; var cpt3 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type }; cpt.Component.Add(cpt1); cpt.Component.Add(cpt2); cpt.Component.Add(cpt3); var parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = cpt, Owner = this.domain, Container = this.elementDef }; var values = new List <string> { "a", "b", "c" }; var cptValueSet = new ParameterValueSet(); cptValueSet.Manual = new ValueArray <string>(values); cptValueSet.Reference = new ValueArray <string>(values); cptValueSet.Computed = new ValueArray <string>(values); cptValueSet.Formula = new ValueArray <string>(values); cptValueSet.Published = new ValueArray <string>(values); parameter2.ValueSet.Add(cptValueSet); var type3 = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "abc", ShortName = "abc" }; var parameter3 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = type3, Owner = this.domain, Container = this.elementDef }; parameter3.ValueSet.Add(this.valueSet); this.elementDef.Parameter.Add(parameter1); this.elementDef.Parameter.Add(parameter2); this.elementDef.Parameter.Add(parameter3); var elementDefRow = new ElementDefinitionRowViewModel(this.elementDef, this.domain, this.session.Object, null); Assert.AreEqual(4, elementDefRow.ContainedRows.Count); Assert.AreSame(parameter1, elementDefRow.ContainedRows[0].Thing); Assert.AreSame(parameter3, elementDefRow.ContainedRows[1].Thing); Assert.AreSame(parameter2, elementDefRow.ContainedRows[2].Thing); }
public void SetUp() { this.excelRows = new List <IExcelRow <Thing> >(); this.owner = new DomainOfExpertise(Guid.NewGuid(), null, null) { Name = "system", ShortName = "SYS" }; // Reference SitedirectoryData var lengthunit = new SimpleUnit(Guid.NewGuid(), null, null); lengthunit.ShortName = "m"; lengthunit.Name = "metre"; var lengthscale = new RatioScale(Guid.NewGuid(), null, null); lengthscale.Unit = lengthunit; lengthscale.ShortName = "m-scale"; lengthscale.Name = "metre scale"; var xcoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "x", ShortName = "x" }; xcoord.PossibleScale.Add(lengthscale); xcoord.DefaultScale = lengthscale; var ycoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "y", ShortName = "y" }; ycoord.PossibleScale.Add(lengthscale); ycoord.DefaultScale = lengthscale; var zcoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "z", ShortName = "z" }; zcoord.PossibleScale.Add(lengthscale); zcoord.DefaultScale = lengthscale; var vector = new ArrayParameterType(Guid.NewGuid(), null, null); vector.Name = "coordinate"; vector.ShortName = "coord"; var xcomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = xcoord }; var ycomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = ycoord }; var zcomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = zcoord }; vector.Component.Add(xcomp); vector.Component.Add(ycomp); vector.Component.Add(zcomp); // iteration data this.iteration = new Iteration(Guid.NewGuid(), null, null); var optionA = new Option(Guid.NewGuid(), null, null) { Name = "Option A", ShortName = "OptionA" }; this.iteration.Option.Add(optionA); var optionB = new Option(Guid.NewGuid(), null, null) { Name = "Option B", ShortName = "OptionB" }; this.iteration.Option.Add(optionB); var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleFiniteState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { ShortName = "state1", Name = "state 1" }; possibleFiniteStateList.PossibleState.Add(possibleFiniteState1); var possibleFiniteState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { ShortName = "state2", Name = "state 2" }; possibleFiniteStateList.PossibleState.Add(possibleFiniteState2); possibleFiniteStateList.DefaultState = possibleFiniteState1; var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), null, null); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteState1 = new ActualFiniteState(Guid.NewGuid(), null, null); actualFiniteState1.PossibleState.Add(possibleFiniteState1); actualFiniteStateList.ActualState.Add(actualFiniteState1); var actualFiniteState2 = new ActualFiniteState(Guid.NewGuid(), null, null); actualFiniteState2.PossibleState.Add(possibleFiniteState2); actualFiniteStateList.ActualState.Add(actualFiniteState2); var elementDefinitionA = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.owner, ShortName = "elementdefinitionA", Name = "element definition A" }; this.iteration.Element.Add(elementDefinitionA); var parameterA1 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = xcoord, Scale = lengthscale, Owner = this.owner }; var parameterValueSetA1 = new ParameterValueSet(Guid.NewGuid(), null, null); var valueArrayA = new ValueArray <string>(new List <string>() { "x" }); parameterValueSetA1.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueSetA1.Manual = valueArrayA; parameterValueSetA1.Computed = valueArrayA; parameterValueSetA1.Reference = valueArrayA; parameterValueSetA1.Formula = valueArrayA; parameterA1.ValueSet.Add(parameterValueSetA1); elementDefinitionA.Parameter.Add(parameterA1); var parameterA2 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = vector, Owner = this.owner }; elementDefinitionA.Parameter.Add(parameterA2); var parameterValueSetA2 = new ParameterValueSet(Guid.NewGuid(), null, null); parameterA2.ValueSet.Add(parameterValueSetA2); var valueArrayA2 = new ValueArray <string>(new List <string>() { "x", "y", "z" }); parameterValueSetA2.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueSetA2.Manual = valueArrayA2; parameterValueSetA2.Computed = valueArrayA2; parameterValueSetA2.Reference = valueArrayA2; parameterValueSetA2.Formula = valueArrayA2; var parameterA3 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = xcoord, Scale = lengthscale, Owner = this.owner, IsOptionDependent = true, }; elementDefinitionA.Parameter.Add(parameterA3); var parameterValueSetA3OptionA = new ParameterValueSet(Guid.NewGuid(), null, null) { ActualOption = optionA }; var valueArrayA3OptionA = new ValueArray <string>(new List <string> { "x" }); parameterValueSetA3OptionA.Manual = valueArrayA3OptionA; parameterValueSetA3OptionA.Reference = valueArrayA3OptionA; parameterValueSetA3OptionA.Computed = valueArrayA3OptionA; parameterValueSetA3OptionA.Formula = valueArrayA3OptionA; parameterA3.ValueSet.Add(parameterValueSetA3OptionA); var parameterValueSetA3OptionB = new ParameterValueSet(Guid.NewGuid(), null, null) { ActualOption = optionB }; var valueArrayA3OptionB = new ValueArray <string>(new List <string>() { "x" }); parameterValueSetA3OptionB.Manual = valueArrayA3OptionB; parameterValueSetA3OptionB.Reference = valueArrayA3OptionB; parameterValueSetA3OptionB.Computed = valueArrayA3OptionB; parameterValueSetA3OptionB.Formula = valueArrayA3OptionB; parameterA3.ValueSet.Add(parameterValueSetA3OptionB); var processedValueSets = new Dictionary <Guid, ProcessedValueSet>(); var assembler = new ParameterSheetRowAssembler(this.iteration, this.owner); assembler.Assemble(processedValueSets); this.excelRows.AddRange(assembler.ExcelRows); }
public void VerifyThatNestedParameterExcelRowPropertiesAreSetForCompoundParameter() { var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "coordinate", ShortName = "coord" }; var component_1 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.length, Scale = this.meter, ShortName = "x" }; compoundParameterType.Component.Add(component_1); var component_2 = new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.text, ShortName = "txt" }; compoundParameterType.Component.Add(component_2); var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = compoundParameterType, Owner = this.systemEngineering }; var parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "A", "A1" }), Computed = new ValueArray <string>(new List <string> { "B", "B1" }), Formula = new ValueArray <string>(new List <string> { "C", "C1" }), ValueSwitch = ParameterSwitchKind.MANUAL }; parameter.ValueSet.Add(parameterValueSet); this.satellite.Parameter.Add(parameter); var nestedElementTreeGenerator = new NestedElementTreeGenerator(); var nestedElements = nestedElementTreeGenerator.Generate(this.option, this.systemEngineering); var rootnode = nestedElements.Single(ne => ne.ShortName == "SAT"); var nestedparameter_1 = rootnode.NestedParameter.Single(x => x.Component == component_1); var excelRow_1 = new NestedParameterExcelRow(nestedparameter_1); Assert.AreEqual("=SAT.coord.x", excelRow_1.ActualValue); Assert.AreEqual("SAT\\coord.x\\option1\\", excelRow_1.ModelCode); Assert.AreEqual("coordinate", excelRow_1.Name); Assert.AreEqual("SYS", excelRow_1.Owner); Assert.AreEqual("coord.x [m]", excelRow_1.ParameterTypeShortName); Assert.AreEqual("NP", excelRow_1.Type); var nestedparameter_2 = rootnode.NestedParameter.Single(x => x.Component == component_2); var excelRow_2 = new NestedParameterExcelRow(nestedparameter_2); Assert.AreEqual("=SAT.coord.txt", excelRow_2.ActualValue); Assert.AreEqual("SAT\\coord.txt\\option1\\", excelRow_2.ModelCode); Assert.AreEqual("coordinate", excelRow_2.Name); Assert.AreEqual("SYS", excelRow_2.Owner); Assert.AreEqual("coord.txt", excelRow_2.ParameterTypeShortName); Assert.AreEqual("NP", excelRow_2.Type); }