/// <summary> /// Gets the equipments of the sub-system /// </summary> /// <param name="usage">The <see cref="ElementUsage"/> representing the equipment</param> public void AddEquipment(ElementUsage usage) { this.equipments.Add(usage); }
private void BuildModelData() { this.model1 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model2 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration1 = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration2 = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.rootDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "rootdef" }; this.def1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "def1" }; this.def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "def2" }; this.usage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage11 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage21 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.usage22 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); this.override1 = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri); this.subscription1 = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri); this.group1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.group2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model1.EngineeringModelSetup = this.modelsetup1; this.model2.EngineeringModelSetup = this.modelsetup2; this.iteration1.IterationSetup = this.iterationSetup1; this.iteration2.IterationSetup = this.iterationSetup2; this.rootDef.Owner = this.domain1; this.def1.Owner = this.domain1; this.def2.Owner = this.domain2; this.usage1.Owner = this.domain1; this.usage1.ElementDefinition = this.def1; this.usage11.Owner = this.domain1; this.usage11.ElementDefinition = this.def1; this.usage2.Owner = this.domain1; this.usage2.ElementDefinition = this.def2; this.usage22.Owner = this.domain1; this.usage22.ElementDefinition = this.def2; this.usage21.Owner = this.domain1; this.usage21.ElementDefinition = this.def2; this.parameter1.Owner = this.domain2; this.parameter1.ParameterType = this.booleanPt; this.parameter1.AllowDifferentOwnerOfOverride = true; this.override1.Parameter = this.parameter1; this.override1.Owner = this.domain2; this.subscription1.Owner = this.domain1; this.group2.ContainingGroup = this.group1; this.parameter1.Group = this.group2; this.model1.Iteration.Add(this.iteration1); this.iteration1.Element.Add(this.def1); this.iteration1.Element.Add(this.def2); this.iteration1.Element.Add(this.rootDef); this.rootDef.ContainedElement.Add(this.usage1); this.rootDef.ContainedElement.Add(this.usage11); this.def1.ContainedElement.Add(this.usage2); this.def1.ContainedElement.Add(this.usage22); this.def1.ContainedElement.Add(this.usage21); this.def2.Parameter.Add(this.parameter1); this.def2.ParameterGroup.Add(this.group1); this.def2.ParameterGroup.Add(this.group2); this.usage1.ParameterOverride.Add(this.override1); this.override1.ParameterSubscription.Add(this.subscription1); this.model2.Iteration.Add(this.iteration2); }
/// <summary> /// Persist the <see cref="ElementUsage"/> containment tree to the ORM layer. Update if it already exists. /// This is typically used during the import of existing data to the Database. /// </summary> /// <param name="transaction"> /// The current <see cref="NpgsqlTransaction"/> to the database. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="elementUsage"> /// The <see cref="ElementUsage"/> instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool UpsertContainment(NpgsqlTransaction transaction, string partition, ElementUsage elementUsage) { var results = new List <bool>(); foreach (var alias in this.ResolveFromRequestCache(elementUsage.Alias)) { results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, elementUsage)); } foreach (var definition in this.ResolveFromRequestCache(elementUsage.Definition)) { results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, elementUsage)); } foreach (var hyperLink in this.ResolveFromRequestCache(elementUsage.HyperLink)) { results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, elementUsage)); } foreach (var parameterOverride in this.ResolveFromRequestCache(elementUsage.ParameterOverride)) { results.Add(this.ParameterOverrideService.UpsertConcept(transaction, partition, parameterOverride, elementUsage)); } return(results.All(x => x)); }
public void SetUp() { this.CleanupExistingFiles(); RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.pluginSettingsService = new Mock <IPluginSettingsService>(); this.openSaveFileDialogService = new Mock <IOpenSaveFileDialogService>(); this.submittableParameterValuesCollector = new Mock <ISubmittableParameterValuesCollector>(); this.permissionService = new Mock <IPermissionService>(); this.dynamicTableChecker = new Mock <IDynamicTableChecker>(); this.messageBoxService = new Mock <IMessageBoxService>(); this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IOpenSaveFileDialogService>()).Returns(this.openSaveFileDialogService.Object); this.serviceLocator.Setup(x => x.GetInstance <ISubmittableParameterValuesCollector>()).Returns(this.submittableParameterValuesCollector.Object); this.serviceLocator.Setup(x => x.GetInstance <IDynamicTableChecker>()).Returns(this.dynamicTableChecker.Object); this.serviceLocator.Setup(x => x.GetInstance <IMessageBoxService>()).Returns(this.messageBoxService.Object); this.assembler = new Assembler(this.uri); this.cache = this.assembler.Cache; this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri) { Name = "model" }; this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { Person = this.person, SelectedDomain = domainOfExpertise }; this.sitedir.Model.Add(this.modelsetup); this.sitedir.Person.Add(this.person); this.sitedir.Domain.Add(domainOfExpertise); this.sitedir.Domain.Add(domainOfExpertise_2); this.sitedir.Domain.Add(domainOfExpertise_3); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.modelsetup.Participant.Add(this.participant); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationsetup }; this.model.Iteration.Add(this.iteration); this.elementDefinition_1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Sat", Name = "Satellite" }; this.elementDefinition_2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Bat", Name = "Battery" }; this.elementUsage_1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_a", Name = "battery a" }; this.elementUsage_2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_b", Name = "battery b" }; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "m" }; var simpleQuantityKind2 = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "v" }; var ratioScale = new RatioScale(Guid.NewGuid(), null, null); simpleQuantityKind.PossibleScale.Add(ratioScale); simpleQuantityKind.DefaultScale = ratioScale; simpleQuantityKind2.PossibleScale.Add(ratioScale); simpleQuantityKind2.DefaultScale = ratioScale; var actualList = new ActualFiniteStateList(Guid.NewGuid(), null, null); actualList.Owner = domainOfExpertise; var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate1", ShortName = "1" }; var possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate2", ShortName = "2" }; possibleList1.PossibleState.Add(possibleState1); possibleList1.PossibleState.Add(possibleState2); actualList.PossibleFiniteStateList.Add(possibleList1); this.actualState_3 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_3.PossibleState.Add(possibleState1); this.actualState_4 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_4.PossibleState.Add(possibleState2); this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = domainOfExpertise, ParameterType = simpleQuantityKind, IsOptionDependent = true, Scale = ratioScale }; var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Owner = domainOfExpertise_3 }; this.parameter.ParameterSubscription.Add(parameterSubscription); this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = domainOfExpertise_2, ParameterType = simpleQuantityKind2, StateDependence = actualList, Scale = ratioScale }; this.parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Owner = domainOfExpertise, Parameter = this.parameter }; var parameterValueset_1 = new ParameterValueSet { ActualOption = option_B, Iid = Guid.NewGuid() }; var parameterValueset_2 = new ParameterValueSet { ActualOption = option_A, Iid = Guid.NewGuid() }; var parameterValueset_3 = new ParameterValueSet { ActualState = this.actualState_3, Iid = Guid.NewGuid() }; var parameterValueset_4 = new ParameterValueSet { ActualState = this.actualState_4, Iid = Guid.NewGuid() }; var parameterSubscriptionValueSetA = new ParameterSubscriptionValueSet { Iid = Guid.NewGuid() }; var parameterSubscriptionValueSetB = new ParameterSubscriptionValueSet { Iid = Guid.NewGuid() }; var values_1 = new List <string> { "2" }; var values_2 = new List <string> { "3" }; var values_3 = new List <string> { "220" }; var emptyValues = new List <string> { "-" }; var publishedValues = new List <string> { "123" }; var subscriptionValues = new List <string> { "456" }; var overrideValueset = new ParameterOverrideValueSet() { ParameterValueSet = parameterValueset_1, Iid = Guid.NewGuid() }; this.iteration.Option.Add(option_A); this.iteration.Option.Add(option_B); this.iteration.DefaultOption = option_A; parameterValueset_1.Manual = new ValueArray <string>(values_1); parameterValueset_1.Reference = new ValueArray <string>(values_1); parameterValueset_1.Computed = new ValueArray <string>(values_1); parameterValueset_1.Formula = new ValueArray <string>(values_1); parameterValueset_1.Published = new ValueArray <string>(publishedValues); parameterValueset_1.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_2.Manual = new ValueArray <string>(values_2); parameterValueset_2.Reference = new ValueArray <string>(values_2); parameterValueset_2.Computed = new ValueArray <string>(values_2); parameterValueset_2.Formula = new ValueArray <string>(values_2); parameterValueset_2.Published = new ValueArray <string>(publishedValues); parameterValueset_2.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_3.Manual = new ValueArray <string>(values_3); parameterValueset_3.Reference = new ValueArray <string>(values_3); parameterValueset_3.Computed = new ValueArray <string>(values_3); parameterValueset_3.Formula = new ValueArray <string>(values_3); parameterValueset_3.Published = new ValueArray <string>(emptyValues); parameterValueset_3.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_4.Manual = new ValueArray <string>(emptyValues); parameterValueset_4.Reference = new ValueArray <string>(emptyValues); parameterValueset_4.Computed = new ValueArray <string>(emptyValues); parameterValueset_4.Formula = new ValueArray <string>(emptyValues); parameterValueset_4.Published = new ValueArray <string>(publishedValues); parameterValueset_4.ValueSwitch = ParameterSwitchKind.MANUAL; overrideValueset.Manual = new ValueArray <string>(values_1); overrideValueset.Reference = new ValueArray <string>(values_1); overrideValueset.Computed = new ValueArray <string>(values_1); overrideValueset.Formula = new ValueArray <string>(values_1); overrideValueset.Published = new ValueArray <string>(publishedValues); overrideValueset.ValueSwitch = ParameterSwitchKind.MANUAL; parameterSubscriptionValueSetA.Manual = new ValueArray <string>(subscriptionValues); parameterSubscriptionValueSetA.ValueSwitch = ParameterSwitchKind.MANUAL; parameterSubscriptionValueSetA.SubscribedValueSet = parameterValueset_1; parameterSubscriptionValueSetB.Manual = new ValueArray <string>(subscriptionValues); parameterSubscriptionValueSetB.ValueSwitch = ParameterSwitchKind.COMPUTED; parameterSubscriptionValueSetB.SubscribedValueSet = parameterValueset_2; this.parameter.ValueSet.Add(parameterValueset_1); this.parameter.ValueSet.Add(parameterValueset_2); this.parameterOverride.ValueSet.Add(overrideValueset); this.parameter2.ValueSet.Add(parameterValueset_3); this.parameter2.ValueSet.Add(parameterValueset_4); parameterSubscription.ValueSet.Add(parameterSubscriptionValueSetA); parameterSubscription.ValueSet.Add(parameterSubscriptionValueSetB); this.elementUsage_1.ExcludeOption.Add(option_A); this.elementUsage_1.ParameterOverride.Add(this.parameterOverride); this.elementDefinition_1.Parameter.Add(this.parameter); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_1); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_2); this.elementDefinition_2.Parameter.Add(this.parameter); this.elementDefinition_2.Parameter.Add(this.parameter2); this.iteration.Element.Add(this.elementDefinition_1); this.iteration.Element.Add(this.elementDefinition_2); this.iteration.TopElement = this.elementDefinition_1; this.iteration.ActualFiniteStateList.Add(actualList); this.iteration.PossibleFiniteStateList.Add(possibleList1); actualList.ActualState.Add(this.actualState_3); actualList.ActualState.Add(this.actualState_4); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.IsVersionSupported(It.IsAny <Version>())).Returns(true); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.reportDesignerViewModel = new ReportDesignerViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object, this.pluginSettingsService.Object); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.iteration = new Iteration(Guid.NewGuid(), this.cache, null); // Option this.option = new Option(Guid.NewGuid(), this.cache, null) { ShortName = "option1", Name = "option1" }; this.iteration.Option.Add(this.option); var engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, null); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null); var iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, null); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null); iterationSetup.Container = engineeringModelSetup; engineeringModel.EngineeringModelSetup = engineeringModelSetup; engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary); this.iteration.IterationSetup = iterationSetup; this.iteration.Container = engineeringModel; // Categories this.cat1 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat1", Name = "cat1" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat1); this.cache.TryAdd( new CacheKey(this.cat1.Iid, null), new Lazy <Thing>(() => this.cat1)); this.cat2 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat2", Name = "cat2" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat2); this.cache.TryAdd( new CacheKey(this.cat2.Iid, null), new Lazy <Thing>(() => this.cat2)); this.cat3 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat3", Name = "cat3" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat3); this.cache.TryAdd( new CacheKey(this.cat3.Iid, null), new Lazy <Thing>(() => this.cat3)); this.superCat = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "superCat", Name = "superCat" }; modelReferenceDataLibrary.DefinedCategory.Add(this.superCat); this.cache.TryAdd( new CacheKey(this.superCat.Iid, null), new Lazy <Thing>(() => this.superCat)); this.subCat = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "subCat", Name = "subCat" }; this.subCat.SuperCategory.Add(this.superCat); modelReferenceDataLibrary.DefinedCategory.Add(this.subCat); this.cache.TryAdd( new CacheKey(this.subCat.Iid, null), new Lazy <Thing>(() => this.subCat)); // Domain of expertise this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, null) { ShortName = "domain", Name = "domain" }; // Element Definitions this.ed1 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed1", Name = "element definition 1", Owner = this.domain, Container = this.iteration }; this.ed2 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed2", Name = "element definition 2", Owner = this.domain, Container = this.iteration }; // Element Usages this.eu = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed2, ShortName = "eu", Name = "element usage", Owner = this.domain }; // Structure this.iteration.TopElement = this.ed1; this.ed1.Category.Add(this.cat1); this.eu.Category.Add(this.cat2); this.ed1.ContainedElement.Add(this.eu); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.uri = new Uri("http://www.rheagroup.com"); this.text = new TextParameterType(Guid.NewGuid(), this.cache, this.uri) { ShortName = "txt", Name = "Text" }; this.length = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { ShortName = "l", Name = "Length" }; this.meter = new RatioScale(Guid.NewGuid(), this.cache, this.uri) { ShortName = "m", Name = "meter" }; this.systemEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "SYS", Name = "System Engineering" }; this.powerEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "PWR", Name = "Power Engineering" }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.option = new Option(Guid.NewGuid(), this.cache, this.uri) { ShortName = "option1", Name = "option 1" }; this.iteration.Option.Add(this.option); this.satellite = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "SAT", Name = "Satellite", Owner = this.systemEngineering }; this.battery = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "BAT", Name = "Battery", Owner = this.powerEngineering }; this.batteryUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ShortName = "batt", ElementDefinition = this.battery, Owner = this.powerEngineering }; this.satellite.ContainedElement.Add(this.batteryUsage); this.iteration.Element.Add(this.satellite); this.iteration.Element.Add(this.battery); this.iteration.TopElement = this.satellite; }
private void InitializeElementDef() { this.rootEd = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Sat", Name = "Satellite" }; this.eqptEd = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "EQT", Name = "eqt" }; this.ssEd = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "SS", Name = "SS" }; this.consumableEd = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Cons", Name = "Consumable" }; var ssUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.ssEd, ShortName = "SS", Name = "SS" }; ssUsage.Category.Add(this.ssCat); var eqtUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.eqptEd, ShortName = "eqt1", Name = "eqt 1" }; eqtUsage1.Category.Add(this.eqtCat); var eqtUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.eqptEd, ShortName = "eqt2", Name = "eqt 2" }; eqtUsage2.Category.Add(this.eqtCat); eqtUsage2.ExcludeOption.Add(this.option_B); var consUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.consumableEd, ShortName = "cons", Name = "consumable" }; consUsage.Category.Add(this.consCat); #region Mass var ssMassP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.mass, IsOptionDependent = true }; this.SetValueSet(ssMassP, this.option_A, "2000"); this.SetValueSet(ssMassP, this.option_B, "3000"); var eqtMassP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.mass, IsOptionDependent = true }; this.SetValueSet(eqtMassP, this.option_A, "500"); this.SetValueSet(eqtMassP, this.option_B, "100"); var consMassP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.mass }; this.SetValueSet(consMassP, null, "200"); this.ssEd.Parameter.Add(ssMassP); this.eqptEd.Parameter.Add(eqtMassP); this.consumableEd.Parameter.Add(consMassP); #endregion #region Margin // define margin parameters var ssMassMarginP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.massMargin, }; this.SetValueSet(ssMassMarginP, null, "20"); var eqtMassMarginP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.massMargin, }; this.SetValueSet(eqtMassMarginP, null, "25"); var consMassMarginP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.massMargin }; this.SetValueSet(consMassMarginP, null, "100"); this.ssEd.Parameter.Add(ssMassMarginP); this.eqptEd.Parameter.Add(eqtMassMarginP); this.consumableEd.Parameter.Add(consMassMarginP); #endregion #region number // define number parameter var eqtNumberP = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = this.number, ExpectsOverride = true }; this.SetValueSet(eqtNumberP, null, "0"); var subscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, }; this.SetValueSet(subscription, eqtNumberP, new List <string> { "10" }); eqtNumberP.ParameterSubscription.Add(subscription); this.eqptEd.Parameter.Add(eqtNumberP); #endregion #region override mass var eq1massOverride1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = eqtMassP }; this.SetValueSet(eq1massOverride1, eqtMassP, new List <string> { "1000", "2000" }); eqtUsage1.ParameterOverride.Add(eq1massOverride1); #endregion this.rootEd.ContainedElement.Add(ssUsage); this.rootEd.ContainedElement.Add(eqtUsage1); this.rootEd.ContainedElement.Add(eqtUsage2); this.rootEd.ContainedElement.Add(consUsage); }
public void Setup() { this.session = new Mock <ISession>(); this.assembler = new Assembler(this.uri); this.permissionService = new Mock <IPermissionService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.cache = this.assembler.Cache; this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri) { Name = "model" }; this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain", ShortName = "DMN" }; this.otherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "otherDomain", ShortName = "ODMN" }; this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { Person = this.person, SelectedDomain = this.domain }; this.modelsetup.ActiveDomain = new List <DomainOfExpertise>() { this.domain, this.otherDomain }; this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); this.sitedir.Model.Add(this.modelsetup); this.sitedir.Person.Add(this.person); this.sitedir.Domain.Add(this.domain); this.sitedir.Domain.Add(this.otherDomain); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.modelsetup.Participant.Add(this.participant); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationsetup }; this.iteration.Element.Add(this.elementDefinition); this.publication = new Publication(Guid.NewGuid(), this.cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "paramtype1", ShortName = "pat1" }, Owner = this.domain }; this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "paramtype2", ShortName = "pat2" }, Owner = this.domain }; this.parameter3 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "paramtypeadd", ShortName = "padd" }, Owner = this.domain }; var parameterforoverride = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "paramtype3", ShortName = "pat3" } }; // Test input var valueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); this.SetScalarValueSet(valueSet); parameterforoverride.ValueSet.Add(valueSet); this.parameter1.ValueSet.Add(valueSet.Clone(false)); this.parameter3.ValueSet.Add(valueSet.Clone(false)); this.parameterOverride1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = parameterforoverride }; this.elementDefinition.Parameter.Add(this.parameter1); this.elementDefinition.Parameter.Add(this.parameter2); this.elementDefinition.Parameter.Add(this.parameter3); this.elementDefinition.Parameter.Add(parameterforoverride); var elementusage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri); this.elementDefinition.ContainedElement.Add(elementusage); elementusage.ParameterOverride.Add(this.parameterOverride1); this.publication.PublishedParameter.Add(this.parameter1); this.publication.PublishedParameter.Add(this.parameter2); this.publication.PublishedParameter.Add(this.parameter3); this.publication.PublishedParameter.Add(this.parameterOverride1); this.publication.CreatedOn = DateTime.Now; this.publication.Domain.Add(this.domain); this.model.Iteration.Add(this.iteration); this.iteration.Publication.Add(this.publication); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Returns(Task.FromResult("some result")); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); }
public void Setup() { this.permissionService = new Mock <IPermissionService>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.serviceLocator = new Mock <IServiceLocator>(); this.thingCreator = new Mock <IThingCreator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()) .Returns(this.thingCreator.Object); this.nestedElementTreeService = new Mock <INestedElementTreeService>(); this.nestedElementTreeService.Setup(x => x.GetNestedElementPath(It.IsAny <ElementUsage>(), It.IsAny <Option>())).Returns(this.nestedElementPath); this.serviceLocator.Setup(x => x.GetInstance <INestedElementTreeService>()).Returns(this.nestedElementTreeService.Object); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain", ShortName = "dom" }; this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri); this.option = new Option(Guid.NewGuid(), this.cache, this.uri); this.category1 = new Category(Guid.NewGuid(), this.cache, this.uri); this.category2 = new Category(Guid.NewGuid(), this.cache, this.uri); this.elementDef = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.elementDef3 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain, Name = "Element definition 1", ShortName = "ED1" }; this.elementDef4 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain, Name = "Element definition 4", ShortName = "ED4" }; this.elementDef4.Category.Add(this.category1); this.elementDef5 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain, Name = "Element definition 5", ShortName = "ED5" }; this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef2, Owner = this.domain, Name = "Element usage 1", ShortName = "EU1" }; this.elementUsage4 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef4, Container = this.elementDef4, Owner = this.domain, Name = "Element usage 4", ShortName = "EU4" }; this.elementUsage4.Category.Add(this.category2); this.elementUsage5 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef5, Container = this.elementDef5, Owner = this.domain, Name = "Element usage 5", ShortName = "EU5" }; this.elementDef5.Category.Add(this.category1); this.elementUsage6 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef4, Container = this.elementDef5, Owner = this.domain, Name = "Element usage 6", ShortName = "EU6" }; this.valueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); this.valueSet.Published = new ValueArray <string>(new List <string> { "1" }); this.valueSet.Manual = new ValueArray <string>(new List <string> { "1" }); this.valueSet.ValueSwitch = ParameterSwitchKind.MANUAL; this.valueSetOverride = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri); this.valueSetOverride.Published = new ValueArray <string>(new List <string> { "1" }); this.valueSetOverride.Manual = new ValueArray <string>(new List <string> { "1" }); this.valueSetOverride.ValueSwitch = ParameterSwitchKind.MANUAL; this.siteDir.Person.Add(this.person); this.siteDir.Model.Add(this.modelSetup); this.modelSetup.IterationSetup.Add(this.iterationSetup); this.modelSetup.Participant.Add(this.participant); this.participant.Person = this.person; this.model.Iteration.Add(this.iteration); this.model.EngineeringModelSetup = this.modelSetup; this.iteration.IterationSetup = this.iterationSetup; this.iteration.Option.Add(this.option); this.iteration.TopElement = this.elementDef; this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(this.elementDef3); this.iteration.Element.Add(this.elementDef2); this.elementDef.ContainedElement.Add(this.elementUsage); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain); }
public void SetUp() { this.nestedElementTreeGenerator = new NestedElementTreeGenerator(); this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary <CDP4Common.Types.CacheKey, Lazy <Thing> >(); this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "SYS", Name = "System" }; this.domainOfExpertise_2 = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "TEST", Name = "Test" }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.option_A = new Option(Guid.NewGuid(), this.cache, this.uri) { ShortName = "OPT_A", Name = "Option A" }; this.option_B = new Option(Guid.NewGuid(), this.cache, this.uri) { ShortName = "OPT_B", Name = "Option B" }; this.elementDefinition_1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Sat", Name = "Satellite" }; this.elementDefinition_2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Bat", Name = "Battery" }; this.elementUsage_1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_a", Name = "battery a" }; this.elementUsage_2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_b", Name = "battery b" }; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "m" }; var simpleQuantityKind2 = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "v" }; this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = simpleQuantityKind }; this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise_2, ParameterType = simpleQuantityKind2 }; this.parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, Parameter = this.parameter }; var parameterValueset_1 = new ParameterValueSet() { ActualOption = this.option_B, Iid = Guid.NewGuid() }; var parameterValueset_2 = new ParameterValueSet() { ActualOption = this.option_A, Iid = Guid.NewGuid() }; var actualList = new ActualFiniteStateList(Guid.NewGuid(), null, null); actualList.Owner = this.domainOfExpertise; var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate1", ShortName = "1" }; var possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate2", ShortName = "2" }; possibleList1.PossibleState.Add(possibleState1); possibleList1.PossibleState.Add(possibleState2); actualList.PossibleFiniteStateList.Add(possibleList1); this.actualState_3 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_3.PossibleState.Add(possibleState1); this.actualState_4 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_4.PossibleState.Add(possibleState2); var parameterValueset_3 = new ParameterValueSet() { ActualState = this.actualState_3, Iid = Guid.NewGuid() }; var parameterValueset_4 = new ParameterValueSet() { ActualState = this.actualState_4, Iid = Guid.NewGuid() }; var values_1 = new List <string> { "2" }; var values_2 = new List <string> { "3" }; var values_3 = new List <string> { "220" }; var values_4 = new List <string> { "0" }; var overrideValueset = new ParameterOverrideValueSet() { ParameterValueSet = parameterValueset_1, Iid = Guid.NewGuid() }; this.iteration.Option.Add(this.option_A); this.iteration.Option.Add(this.option_B); this.iteration.DefaultOption = this.option_A; parameterValueset_1.Manual = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Reference = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Computed = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Formula = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_2.Manual = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Reference = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Computed = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Formula = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_3.Manual = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Reference = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Computed = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Formula = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_4.Manual = new CDP4Common.Types.ValueArray <string>(values_4); parameterValueset_4.Reference = new CDP4Common.Types.ValueArray <string>(values_4); parameterValueset_4.Computed = new CDP4Common.Types.ValueArray <string>(values_4); parameterValueset_4.Formula = new CDP4Common.Types.ValueArray <string>(values_4); parameterValueset_4.ValueSwitch = ParameterSwitchKind.MANUAL; overrideValueset.Manual = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Reference = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Computed = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Formula = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.ValueSwitch = ParameterSwitchKind.MANUAL; this.parameter.ValueSet.Add(parameterValueset_1); this.parameter.ValueSet.Add(parameterValueset_2); this.parameterOverride.ValueSet.Add(overrideValueset); this.parameter2.ValueSet.Add(parameterValueset_3); this.parameter2.ValueSet.Add(parameterValueset_4); this.elementUsage_1.ExcludeOption.Add(this.option_A); this.elementUsage_1.ParameterOverride.Add(this.parameterOverride); this.elementDefinition_1.Parameter.Add(this.parameter); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_1); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_2); this.elementDefinition_2.Parameter.Add(this.parameter); this.elementDefinition_2.Parameter.Add(this.parameter2); this.iteration.Element.Add(this.elementDefinition_1); this.iteration.Element.Add(this.elementDefinition_2); this.iteration.TopElement = this.elementDefinition_1; this.iteration.ActualFiniteStateList.Add(actualList); this.iteration.PossibleFiniteStateList.Add(possibleList1); actualList.ActualState.Add(this.actualState_3); actualList.ActualState.Add(this.actualState_4); }
public void Setup() { this.cache = new List <Thing>(); RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.uri = new Uri("http://test.com"); this.assembler = new Assembler(this.uri); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.pt = new TextParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.sitedir.Person.Add(person); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "TestDoE" }; this.sitedir.Domain.Add(this.domain); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.elementDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "1" }; this.elementDef.Owner = this.domain; this.elementDef.Container = this.iteration; this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person }; this.participant.Domain.Add(this.domain); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.elementDef, ParameterType = this.pt, Owner = this.elementDef.Owner }; var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.domain, Parameter = parameter, Container = this.elementDef }; var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { ElementDefinition = this.elementDef }; elementUsage.ParameterOverride.Add(parameterOverride); elementUsage.Container = this.iteration; this.elementDef.ContainedElement.Add(elementUsage); this.model.Iteration.Add(this.iteration); var iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration.IterationSetup = iterationSetup; this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "ModelSetup" }; this.engineeringModelSetup.IterationSetup.Add(iterationSetup); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.srdl.ParameterType.Add(this.pt); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.mrdl.RequiredRdl = this.srdl; this.engineeringModelSetup.RequiredRdl.Add(this.mrdl); this.model.EngineeringModelSetup = this.engineeringModelSetup; this.model.EngineeringModelSetup.Participant.Add(this.participant); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) } }); this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.assembler.Cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model)); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <IterationTrackParameterDetailViewModel>())).Returns(new BaseDialogResult(true)); }
public void SetUp() { this.assembler = new Assembler(this.credentials.Uri); this.dal = new Mock <IDal>(); this.dal.SetupProperty(d => d.Session); this.assembler = new Assembler(this.credentials.Uri); this.session = new Mock <ISession>(); this.session.Setup(x => x.Dal).Returns(this.dal.Object); this.session.Setup(x => x.Credentials).Returns(this.credentials); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri) { Container = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri) { EngineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri) }, IterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri) { IterationNumber = 1 } }; var domain = new DomainOfExpertise(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri) { Name = "Domain" }; var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri) { Name = "ElementDefinition", ShortName = "ED", Container = this.iteration, Owner = domain }; var elementUsage = new ElementUsage(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri) { Name = "ElementUsage", ShortName = "EU", Owner = domain }; elementDefinition.ContainedElement.Add(elementUsage); elementUsage.ElementDefinition = elementDefinition; var parameterType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.credentials.Uri) { Name = "P_SimpleQuantityKind" }; var parameter = new Parameter { Iid = Guid.NewGuid(), ParameterType = parameterType, Scale = parameterType.DefaultScale, Owner = domain }; this.iteration.Element.Add(elementDefinition); this.iteration.Element.FirstOrDefault()?.Parameter.Add(parameter); }
public void SetUp() { this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(new ServiceLocatorProvider(() => this.serviceLocator.Object)); this.serviceLocator.Setup(x => x.GetInstance <IMetaDataProvider>()).Returns(new MetaDataProvider()); var siteDirectory = new SiteDirectory(Guid.NewGuid(), null, null); var domain1 = new DomainOfExpertise(Guid.NewGuid(), null, null); siteDirectory.Domain.Add(domain1); var domain2 = new DomainOfExpertise(Guid.NewGuid(), null, null); siteDirectory.Domain.Add(domain2); var alias = new Alias(Guid.NewGuid(), null, null); domain1.Alias.Add(alias); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); siteDirectory.Model.Add(engineeringModelSetup); var iterationSetup = new IterationSetup(Guid.NewGuid(), null, null); engineeringModelSetup.IterationSetup.Add(iterationSetup); var participantRole1 = new ParticipantRole(Guid.NewGuid(), null, null); siteDirectory.ParticipantRole.Add(participantRole1); var participantRole2 = new ParticipantRole(Guid.NewGuid(), null, null); siteDirectory.ParticipantRole.Add(participantRole2); var person1 = new Person(Guid.NewGuid(), null, null); siteDirectory.Person.Add(person1); var personRole1 = new PersonRole(Guid.NewGuid(), null, null); siteDirectory.PersonRole.Add(personRole1); var siteReferenceDataLibrary1 = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary1); var engineeringModel = new EngineeringModel(Guid.NewGuid(), null, null); engineeringModel.EngineeringModelSetup = engineeringModelSetup; engineeringModelSetup.EngineeringModelIid = engineeringModel.Iid; this.iteration = new Iteration(Guid.NewGuid(), null, null); this.iteration.IterationSetup = iterationSetup; iterationSetup.IterationIid = this.iteration.Iid; engineeringModel.Iteration.Add(this.iteration); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null); modelReferenceDataLibrary.RequiredRdl = siteReferenceDataLibrary1; engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary); var participant = new Participant(Guid.NewGuid(), null, null); participant.Person = person1; participant.Domain.Add(domain1); participant.Role = participantRole1; engineeringModelSetup.Participant.Add(participant); var elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null); this.iteration.Element.Add(elementDefinition1); var elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null); this.iteration.Element.Add(elementDefinition2); var elementUsage = new ElementUsage(Guid.NewGuid(), null, null); elementDefinition1.ContainedElement.Add(elementUsage); elementUsage.ElementDefinition = elementDefinition2; }
/// <summary> /// Add an Contained Element row view model to the list of <see cref="ContainedElement"/> /// </summary> /// <param name="containedElement"> /// The <see cref="ContainedElement"/> that is to be added /// </param> private ElementUsageRowViewModel AddContainedElementRowViewModel(ElementUsage containedElement) { return(new ElementUsageRowViewModel(containedElement, this.Session, this)); }
public void Setup() { this.permissionService = new Mock <IPermissionService>(); this.session = new Mock <ISession>(); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain", ShortName = "dom" }; this.serviceLocator = new Mock <IServiceLocator>(); this.thingCreator = new Mock <IThingCreator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()) .Returns(this.thingCreator.Object); this.nestedElementTreeService = new Mock <INestedElementTreeService>(); this.nestedElementTreeService.Setup(x => x.GetNestedElementPath(It.IsAny <ElementDefinition>(), It.IsAny <Option>())).Returns(this.nestedElementPath); this.serviceLocator.Setup(x => x.GetInstance <INestedElementTreeService>()).Returns(this.nestedElementTreeService.Object); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri); this.option = new Option(Guid.NewGuid(), this.cache, this.uri); this.category = new Category(Guid.NewGuid(), this.cache, this.uri); this.elementDef = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.elementDef.Category.Add(this.category); this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef2, Owner = this.domain }; this.siteDir.Person.Add(this.person); this.siteDir.Model.Add(this.modelSetup); this.modelSetup.IterationSetup.Add(this.iterationSetup); this.modelSetup.Participant.Add(this.participant); this.participant.Person = this.person; this.model.Iteration.Add(this.iteration); this.model.EngineeringModelSetup = this.modelSetup; this.iteration.IterationSetup = this.iterationSetup; this.iteration.Option.Add(this.option); this.iteration.TopElement = this.elementDef; this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(this.elementDef2); this.elementDef.ContainedElement.Add(this.elementUsage); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain); }
public void Setup() { this.assembler = new Assembler(this.uri); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session = new Mock <ISession>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "state1" }; this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "state2" }; this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, 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(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }; this.actualState2 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, 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(), this.assembler.Cache, this.uri) { Name = "option1" }; this.option2 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "option2" }; this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; this.enum1 = new EnumerationValueDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "enum1" }; this.enum2 = new EnumerationValueDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "enum2" }; this.enumPt = new EnumerationParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.enumPt.ValueDefinition.Add(this.enum1); this.enumPt.ValueDefinition.Add(this.enum2); this.cptType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType, ShortName = "c1" }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.enumPt, ShortName = "c2" }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "active", ShortName = "active" }; this.parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain, ParameterType = this.qqParamType }; this.cptParameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain, ParameterType = this.cptType, IsOptionDependent = true, StateDependence = this.stateList }; this.cptParameter.ValueSet.Add(new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri) { ActualOption = this.option1, ActualState = this.stateList.ActualState.First() }); this.cptParameter.ValueSet.Add(new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri) { ActualOption = this.option1, ActualState = this.stateList.ActualState.Last() }); this.cptParameter.ValueSet.Add(new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri) { ActualOption = this.option2, ActualState = this.stateList.ActualState.First() }); this.cptParameter.ValueSet.Add(new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri) { ActualOption = this.option2, ActualState = this.stateList.ActualState.Last() }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, 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(), this.assembler.Cache, 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(), this.assembler.Cache, this.uri); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri) { GivenName = "test", Surname = "test" }; this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(this.person); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, 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> >()); }
public void Setup() { this.domain = new DomainOfExpertise(Guid.NewGuid(), null, null) { Name = "domain", ShortName = "d" }; this.elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.domain, ShortName = "Sat" }; this.elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.domain, ShortName = "Bat" }; this.elementUsage = new ElementUsage(Guid.NewGuid(), null, null) { ShortName = "battery_1", ElementDefinition = this.elementDefinition2 }; this.elementDefinition1.ContainedElement.Add(this.elementUsage); this.parameterOverride = new ParameterOverride(Guid.NewGuid(), null, null) { Owner = this.domain }; this.parameter = new Parameter(Guid.NewGuid(), null, null) { Owner = this.domain }; this.parameter.ParameterType = new BooleanParameterType(Guid.NewGuid(), null, null) { ShortName = "bool" }; this.parameter.IsOptionDependent = true; this.parameter.Scale = new LogarithmicScale(Guid.NewGuid(), null, null); this.parameter.StateDependence = new ActualFiniteStateList(Guid.NewGuid(), null, null); this.parameter.Group = new ParameterGroup(Guid.NewGuid(), null, null); this.parameterOverride.Parameter = this.parameter; this.elementDefinition2.Parameter.Add(this.parameter); 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.elementDefinition1); this.iteration.Element.Add(this.elementDefinition2); this.elementUsage.ParameterOverride.Add(this.parameterOverride); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.iteration = new Iteration(Guid.NewGuid(), this.cache, null); var engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, null); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null); var iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, null); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null); engineeringModel.EngineeringModelSetup = engineeringModelSetup; engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary); this.iteration.Container = engineeringModel; iterationSetup.Container = engineeringModelSetup; this.iteration.IterationSetup = iterationSetup; this.iteration.Container = engineeringModel; // Option this.option = new Option(Guid.NewGuid(), this.cache, null) { ShortName = "option1", Name = "option1" }; this.iteration.Option.Add(this.option); // Categories this.cat1 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat1", Name = "cat1" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat1); this.cache.TryAdd( new CacheKey(this.cat1.Iid, null), new Lazy <Thing>(() => this.cat1)); this.cat2 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat2", Name = "cat2" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat2); this.cache.TryAdd( new CacheKey(this.cat2.Iid, null), new Lazy <Thing>(() => this.cat2)); this.cat3 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "cat3", Name = "cat3" }; modelReferenceDataLibrary.DefinedCategory.Add(this.cat3); this.cache.TryAdd( new CacheKey(this.cat3.Iid, null), new Lazy <Thing>(() => this.cat3)); // Domain of expertise this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, null) { ShortName = "domain", Name = "domain" }; this.session = new Mock <ISession>(); this.session.Setup(x => x.QuerySelectedDomainOfExpertise(It.IsAny <Iteration>())).Returns(this.domain); // Element Definitions this.ed1 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed1", Name = "element definition 1", Owner = this.domain, Container = this.iteration }; this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, null); var parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, null) { Reference = new ValueArray <string>(new[] { "1" }), Computed = new ValueArray <string>(new[] { "2" }), Formula = new ValueArray <string>(new[] { "3" }), Manual = new ValueArray <string>(new[] { "4" }), Published = new ValueArray <string>(new[] { "5" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.parameter1.Owner = this.domain; this.parameter1.ParameterType = new SimpleQuantityKind { ShortName = "par" }; this.parameter1.ValueSet.Add(parameterValueSet); this.ed2p = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed2p", Name = "element definition 2p", Owner = this.domain, Container = this.iteration }; this.ed2n = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed2n", Name = "element definition 2n", Owner = this.domain, Container = this.iteration }; this.ed3 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed3", Name = "element definition 3", Owner = this.domain, Container = this.iteration }; this.ed4 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed4", Name = "element definition 4", Owner = this.domain, Container = this.iteration }; this.ed5 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed5", Name = "element definition 5 same category", Owner = this.domain, Container = this.iteration }; this.ed6 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed6", Name = "element definition 6 no category", Owner = this.domain, Container = this.iteration }; this.ed7 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { ShortName = "ed7", Name = "element definition 7 ", Owner = this.domain, Container = this.iteration }; // Element Usages this.eu12p1 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed2p, ShortName = "eu12p1", Name = "element usage 1->2p #1", Owner = this.domain }; this.eu12p2 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed2p, ShortName = "eu12p2", Name = "element usage 1->2p #2", Owner = this.domain }; this.eu12n1 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed2n, ShortName = "eu12n1", Name = "element usage 1->2n #1", Owner = this.domain }; this.eu12n2 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed2n, ShortName = "eu12n2", Name = "element usage 1->2n #2", Owner = this.domain }; this.eu2p31 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed3, ShortName = "eu2p31", Name = "element usage 2p->3 #1", Owner = this.domain }; this.eu2p32 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed3, ShortName = "eu2p32", Name = "element usage 2p->3 #2", Owner = this.domain }; this.eu2n31 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed3, ShortName = "eu2n31", Name = "element usage 2n->3 #1", Owner = this.domain }; this.eu2n32 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed3, ShortName = "eu2n32", Name = "element usage 2n->3 #2", Owner = this.domain }; this.eu4 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed4, ShortName = "eu4", Name = "element usage 1->4", Owner = this.domain }; this.eu5 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed5, ShortName = "eu5", Name = "element usage 4->5", Owner = this.domain }; this.eu6 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed6, ShortName = "eu6", Name = "element usage 5->6", Owner = this.domain }; this.eu7 = new ElementUsage(Guid.NewGuid(), this.cache, null) { ElementDefinition = this.ed7, ShortName = "eu7", Name = "element usage 6->7", Owner = this.domain }; // Structure this.iteration.TopElement = this.ed1; this.ed1.Category.Add(this.cat1); this.eu12n1.Category.Add(this.cat2); this.ed1.ContainedElement.Add(this.eu12n1); this.ed1.ContainedElement.Add(this.eu12n2); this.eu12p1.Category.Add(this.cat2); this.ed1.ContainedElement.Add(this.eu12p1); this.ed1.ContainedElement.Add(this.eu12p2); this.ed2n.ContainedElement.Add(this.eu2n31); this.ed2n.ContainedElement.Add(this.eu2n32); this.eu2p31.Category.Add(this.cat3); this.ed2p.ContainedElement.Add(this.eu2p31); this.ed2p.ContainedElement.Add(this.eu2p32); this.eu4.Category.Add(this.cat2); this.ed1.ContainedElement.Add(this.eu4); this.ed4.ContainedElement.Add(this.eu5); this.ed5.ContainedElement.Add(this.eu6); this.ed7.Category.Add(this.cat3); this.ed6.ContainedElement.Add(this.eu7); // Product tree: // ["cat1"] --> "ed1" // ["cat2"] +--> "ed1.eu12n1" // [ ] +--> "ed1.eu12n1.eu2n31" // [ ] +--> "ed1.eu12n1.eu2n32" // [ ] + +> "ed1.eu12n2" // [ ] +--> "ed1.eu12n2.eu2n31" // [ ] +--> "ed1.eu12n2.eu2n32" // ["cat2"] +--> "ed1.eu12p1" // ["cat3"] +--> "ed1.eu12p1.eu2p31" // [ ] +--> "ed1.eu12p1.eu2p32" // [ ] + --> "ed1.eu12p2" // ["cat3"] +--> "ed1.eu12p2.eu2p31" // [ ] +--> "ed1.eu12p2.eu2p32" // ["cat2"] +--> "ed1.eu4" // [ ] +--> "ed1.eu4.eu5" // [ ] +--> "ed1.eu4.eu5.eu6" // ["cat3"] +--> "ed1.eu4.eu5.eu6.eu7" }
public void SetUp() { this.assembler = new Assembler(this.uri); 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.option1 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "option1" }; this.option2 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "option2" }; this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "state1" }; this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "state2" }; this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }); this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.FORBIDDEN }); this.stateList.PossibleFiniteStateList.Add(this.posStateList); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "active", ShortName = "active" }; this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "other", ShortName = "other" }; this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; this.boolPt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); // Array parameter type with components this.apType = new ArrayParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); // compound parameter type with components this.cptType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType, ShortName = "c1" }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType, ShortName = "c2" }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration.Element.Add(this.elementDefinition); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); var engineeringModel = new EngineeringModel(Guid.NewGuid(), null, null); this.iteration.Container = engineeringModel; this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1; this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2; this.parameter1 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameterCompound = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound); this.iteration.Element.Add(elementDefinitionForUsage1); this.iteration.Element.Add(elementDefinitionForUsage2); this.elementDefinition.Parameter.Add(this.parameter1); this.elementDefinition.Parameter.Add(this.parameterCompound); this.elementDefinition.Parameter.Add(this.parameter5ForSubscription); this.person = new Person(Guid.NewGuid(), null, null) { GivenName = "test", Surname = "test" }; this.participant = new Participant(Guid.NewGuid(), null, null) { Person = this.person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); modelSetup.Participant.Add(this.participant); engineeringModel.EngineeringModelSetup = modelSetup; }
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); }
/// <summary> /// Asserts whether the <paramref name="usage"/> is part of this extra-mass contributor category /// </summary> /// <param name="usage">The <see cref="ElementUsage"/></param> /// <returns>True if it is</returns> public bool IsContributor(ElementUsage usage) { return(!this.ContributionCategories.Except(usage.Category).Any()); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.uri = new Uri("http://www.rheagroup.com"); this.textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri); this.textParameterType.Name = "text"; this.textParameterType.ShortName = "TXT"; var satellite = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); satellite.ShortName = "Sat"; satellite.Name = "Satellite"; var battery = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); battery.ShortName = "Bat"; battery.Name = "Battery"; var elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri); elementUsage.ElementDefinition = battery; satellite.ContainedElement.Add(elementUsage); this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); this.parameter.ParameterType = this.textParameterType; satellite.Parameter.Add(this.parameter); this.parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri); this.parameterOverride.Parameter = this.parameter; var parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); parameterValueSet.Manual = new ValueArray <string>(new List <string> { "1" }); parameterValueSet.Reference = new ValueArray <string>(new List <string> { "2" }); parameterValueSet.Computed = new ValueArray <string>(new List <string> { "3" }); parameterValueSet.Formula = new ValueArray <string>(new List <string> { "-" }); parameterValueSet.Published = new ValueArray <string>(new List <string> { "-" }); parameterValueSet.ValueSwitch = ParameterSwitchKind.MANUAL; this.parameter.ValueSet.Add(parameterValueSet); var parameterOverrideValueSet = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri); parameterOverrideValueSet.Manual = new ValueArray <string>(new List <string> { "1.1" }); parameterOverrideValueSet.Reference = new ValueArray <string>(new List <string> { "2.1" }); parameterOverrideValueSet.Computed = new ValueArray <string>(new List <string> { "3.1" }); parameterOverrideValueSet.Formula = new ValueArray <string>(new List <string> { "-" }); parameterOverrideValueSet.Published = new ValueArray <string>(new List <string> { "-" }); parameterOverrideValueSet.ValueSwitch = ParameterSwitchKind.MANUAL; this.parameterOverride.ValueSet.Add(parameterOverrideValueSet); parameterOverrideValueSet.ParameterValueSet = parameterValueSet; elementUsage.ParameterOverride.Add(this.parameterOverride); var parameterSubscribtionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri); parameterSubscribtionValueSet.Manual = new ValueArray <string>(new List <string> { "1.2" }); parameterSubscribtionValueSet.ValueSwitch = ParameterSwitchKind.MANUAL; parameterSubscribtionValueSet.SubscribedValueSet = parameterValueSet; var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); this.parameter.ParameterSubscription.Add(parameterSubscription); parameterSubscription.ValueSet.Add(parameterSubscribtionValueSet); this.processedValueSets = new Dictionary <Guid, ProcessedValueSet>(); var valueSetValue = new ValueSetValues(0, this.textParameterType, ParameterSwitchKind.COMPUTED, "a gazilion", "a gazilion", "a gazilion", "a gazilion"); var parameterValueSetProcessedValueSet = new ProcessedValueSet(parameterValueSet, ValidationResultKind.Valid); parameterValueSetProcessedValueSet.UpdateClone(valueSetValue); var parameterOverrideValueSetProcessedValueSet = new ProcessedValueSet(parameterOverrideValueSet, ValidationResultKind.Valid); parameterOverrideValueSetProcessedValueSet.UpdateClone(valueSetValue); var parameterSubscribtionValueSetProcessedValueSet = new ProcessedValueSet(parameterSubscribtionValueSet, ValidationResultKind.Valid); parameterSubscribtionValueSetProcessedValueSet.UpdateClone(valueSetValue); this.processedValueSets.Add(parameterValueSetProcessedValueSet.OriginalThing.Iid, parameterValueSetProcessedValueSet); this.processedValueSets.Add(parameterOverrideValueSetProcessedValueSet.OriginalThing.Iid, parameterOverrideValueSetProcessedValueSet); this.processedValueSets.Add(parameterSubscribtionValueSetProcessedValueSet.OriginalThing.Iid, parameterSubscribtionValueSetProcessedValueSet); }
public ElementLayout(int apiVersion, EventHandler handler, ElementFormat format, byte offset, ElementUsage usage, byte usageIndex) : base(apiVersion, handler) { mFormat = format; mOffset = offset; mUsage = usage; mUsageIndex = usageIndex; }
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.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); var testDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); var subscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); subscription.Owner = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "Other Domain" }; 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 paramSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri); paramSubscriptionValueSet.Manual = new ValueArray <string>(new[] { "m1" }); paramSubscriptionValueSet.ValueSwitch = ParameterSwitchKind.REFERENCE; paramSubscriptionValueSet.SubscribedValueSet = paramValueSet; var testParamType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); this.parameter = new Parameter { Owner = testDomain, ParameterType = testParamType }; 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); var option1 = new Option(Guid.NewGuid(), this.cache, this.uri) { Name = "opt1" }; var option2 = new Option(Guid.NewGuid(), this.cache, this.uri) { Name = "opt2" }; this.iteration.Option.Add(option1); this.iteration.Option.Add(option2); this.iteration.Element.Add(elementDefinition); var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); actualFiniteStateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri)); actualFiniteStateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri)); this.iteration.ActualFiniteStateList.Add(actualFiniteStateList); var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); modelSetup.ActiveDomain.Add(testDomain); 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); this.srdl.Scale.Add(new RatioScale(Guid.NewGuid(), this.cache, this.uri)); 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); 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.parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Container = this.parameter }; this.parameterSubscription.ValueSet.Add(paramSubscriptionValueSet); var elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri); elementDefinition.ContainedElement.Add(elementUsage); elementUsage.ElementDefinition = elementDefinition; 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.parameterSubscription.Owner = subscription.Owner; var pt = new TextParameterType(); this.parameter.ParameterType = pt; this.parameter.ParameterSubscription.Add(this.parameterSubscription); this.parameterClone = this.parameter.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, this.parameterClone); 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 VerifyCreateParameterOverride() { var vm = new ProductTreeViewModel(this.option, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object, null); var revisionNumber = typeof(Iteration).GetProperty("RevisionNumber"); revisionNumber.SetValue(this.iteration, 50); var elementdef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.iteration }; var boolParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = elementdef, ElementDefinition = elementdef }; var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.domain, Container = elementUsage, ParameterType = boolParamType }; elementdef.Parameter.Add(parameter); var published = new ValueArray <string>(new List <string> { "published" }); var paramValueSet = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri) { Published = published, Manual = published, Computed = published, ValueSwitch = ParameterSwitchKind.COMPUTED }; parameter.ValueSet.Add(paramValueSet); var usageRow = new ElementUsageRowViewModel(elementUsage, this.option, this.session.Object, null); var parameterRow = new ParameterRowViewModel(parameter, this.option, this.session.Object, usageRow); this.iteration.TopElement = elementdef; vm.SelectedThing = parameterRow; Assert.IsTrue(vm.CreateOverrideCommand.CanExecute(null)); vm.SelectedThing = null; vm.CreateOverrideCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Never); vm.SelectedThing = vm.TopElement.Single(); vm.CreateOverrideCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Never); vm.SelectedThing = parameterRow; vm.CreateOverrideCommand.Execute(parameter); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); vm.PopulateContextMenu(); Assert.AreEqual(7, vm.ContextMenu.Count); }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.thingDialognavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.option1 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "1" }; this.option2 = new Option(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "2" }; this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }); this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.FORBIDDEN }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; // Array parameter type with components this.apType = new ArrayParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); // compound parameter type with components this.cptType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; var engModel = new EngineeringModel(Guid.NewGuid(), null, null); var modelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); var person = new Person(Guid.NewGuid(), null, null) { GivenName = "test", Surname = "test" }; var participant = new Participant(Guid.NewGuid(), null, null) { Person = person }; modelSetup.Participant.Add(participant); engModel.EngineeringModelSetup = modelSetup; this.session.Setup(x => x.ActivePerson).Returns(person); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration.Element.Add(this.elementDefinition); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); engModel.Iteration.Add(this.iteration); this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1; this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2; this.parameterGroup1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup3 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup1ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup2ForUsage2 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterGroup3ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter3 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter4 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameterForStates = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain, StateDependence = this.stateList }; this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter6ForOverride = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter6Override = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = this.parameter6ForOverride, Owner = this.activeDomain }; this.parameterArray = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.apType, Owner = this.someotherDomain }; this.parameterCompound = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.activeDomain }; this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound); this.parameterForOptions = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain, IsOptionDependent = true }; this.elementDefinition.ParameterGroup.Add(this.parameterGroup1); this.elementDefinition.ParameterGroup.Add(this.parameterGroup2); this.elementDefinition.ParameterGroup.Add(this.parameterGroup3); this.elementDefinitionForUsage2.ParameterGroup.Add(this.parameterGroup2ForUsage2); this.iteration.Element.Add(elementDefinitionForUsage1); this.iteration.Element.Add(elementDefinitionForUsage2); this.parameterGroup3.ContainingGroup = this.parameterGroup1; this.parameterGroup3ForUsage1.ContainingGroup = this.parameterGroup1ForUsage1; this.parameter4.Group = this.parameterGroup3; }
private void SetupElementDefinitionsAndUsages() { this.TestElementDefinition = new ElementDefinition(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "testElementDefinition", Owner = this.Domain, Container = this.Iteration, ShortName = "testElementDefinition" }; this.elementDefinition2 = new ElementDefinition(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "testElementDefinition2", Owner = this.Domain, Container = this.Iteration, ShortName = "testElementDefinition2" }; this.elementDefinition3 = new ElementDefinition(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "testElementDefinition3", Owner = this.Domain, Container = this.Iteration, ShortName = "testElementDefinition3" }; this.elementDefinition4 = new ElementDefinition(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "Generic Equipment", Owner = this.Domain, Container = this.Iteration, ShortName = "testElementDefinition4" }; this.Iteration.Element.Add(this.TestElementDefinition); this.Iteration.Element.Add(this.elementDefinition2); this.Iteration.Element.Add(this.elementDefinition3); this.Iteration.Element.Add(this.elementDefinition4); this.SetupParameter(); this.TestElementDefinition.Parameter.Add(this.Parameter); this.TestElementDefinition.Parameter.Add(this.Parameter2); this.TestElementDefinition.Parameter.Add(this.Parameter3); this.elementDefinition2.Parameter.Add(this.Parameter4); this.elementDefinition4.Parameter.Add(this.Parameter5); this.elementDefinition4.Parameter.Add(this.Parameter6); this.elementDefinition4.Parameter.Add(this.Parameter7); var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Owner = this.Domain, Parameter = this.Parameter }; var elementUsage = new ElementUsage(Guid.NewGuid(), this.Assembler.Cache, this.uri) { ElementDefinition = this.TestElementDefinition, Owner = this.Domain }; elementUsage.ParameterOverride.Add(parameterOverride); this.TestElementDefinition.ContainedElement.Add(elementUsage); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri) { ShortName = "TST", Name = "Test" }; this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri) { IterationNumber = 1, Description = "iteraiton 1" }; this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup); this.siteDirectory.Model.Add(this.engineeringModelSetup); this.person = new Person(Guid.NewGuid(), this.cache, this.uri) { GivenName = "John", Surname = "Doe" }; this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain" }; this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { Person = this.person, SelectedDomain = this.domain }; this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.engineeringModelSetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationSetup }; this.engineeringModel.Iteration.Add(this.iteration); this.modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary); this.modelReferenceDataLibrary.RequiredRdl = this.siteReferenceDataLibrary; this.siteDirectory.SiteReferenceDataLibrary.Add(this.siteReferenceDataLibrary); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain); // PossibleElementDefinitionCategory this.elementDefinitionCategory_1 = new Category(Guid.NewGuid(), this.cache, this.uri) { Name = "Batteries", ShortName = "BAT" }; this.elementDefinitionCategory_1.PermissibleClass.Add(ClassKind.ElementDefinition); this.siteReferenceDataLibrary.DefinedCategory.Add(this.elementDefinitionCategory_1); this.elementDefinitionCategory_2 = new Category(Guid.NewGuid(), this.cache, this.uri) { Name = "Reaction Wheels", ShortName = "RW" }; this.elementDefinitionCategory_2.PermissibleClass.Add(ClassKind.ElementDefinition); this.siteReferenceDataLibrary.DefinedCategory.Add(this.elementDefinitionCategory_2); // PossibleActualFiniteStateList this.possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri) { Name = "System Modes", ShortName = "SM", Owner = this.domain }; this.possibleFiniteState_on = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "On", ShortName = "On" }; this.possibleFiniteStateList.PossibleState.Add(this.possibleFiniteState_on); this.possibleFiniteState_off = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "Off", ShortName = "Off" }; this.possibleFiniteStateList.PossibleState.Add(this.possibleFiniteState_off); this.possibleFiniteState_standby = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "stand by", ShortName = "stby" }; this.possibleFiniteStateList.PossibleState.Add(this.possibleFiniteState_standby); this.iteration.PossibleFiniteStateList.Add(this.possibleFiniteStateList); this.actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteStateList.PossibleFiniteStateList.Add(this.possibleFiniteStateList); this.actualFinitateSte_on = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteStateList.ActualState.Add(this.actualFinitateSte_on); this.actualFinitateSte_on.PossibleState.Add(this.possibleFiniteState_on); this.actualFinitateSte_off = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteStateList.ActualState.Add(this.actualFinitateSte_off); this.actualFinitateSte_off.PossibleState.Add(this.possibleFiniteState_off); this.actualFinitateSte_standby = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteStateList.ActualState.Add(this.actualFinitateSte_standby); this.actualFinitateSte_standby.PossibleState.Add(this.possibleFiniteState_standby); this.iteration.ActualFiniteStateList.Add(this.actualFiniteStateList); this.sourceParameterType_1 = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "QuantityKind", ShortName = "QK" }; this.sourceParameterTypes_1 = new List <ParameterType> { this.sourceParameterType_1 }; // PossibleTargetMappingParameterType this.mappingParameterType_1 = new TextParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "Mapping 1", ShortName = "map1" }; this.siteReferenceDataLibrary.ParameterType.Add(this.mappingParameterType_1); this.mappingParameterType_2 = new TextParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "Mapping 2", ShortName = "map2" }; this.siteReferenceDataLibrary.ParameterType.Add(this.mappingParameterType_2); // PossibleTargetValueParameterType this.valueParameterType_1 = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "Power Consumption", ShortName = "PWC" }; this.siteReferenceDataLibrary.ParameterType.Add(this.valueParameterType_1); this.simpleQuantityKind_2 = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "Duty Cycle", ShortName = "DC" }; this.siteReferenceDataLibrary.ParameterType.Add(this.simpleQuantityKind_2); // ElementDefinitions this.rootElementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "Satellite", ShortName = "SAT" }; this.iteration.Element.Add(this.rootElementDefinition); this.elementDefinition_1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "reaction wheel", ShortName = "RW" }; var sourceParameterValueset1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "100" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; var sourceParameter_1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.sourceParameterType_1, Owner = this.domain, ValueSet = { sourceParameterValueset1 } }; var mappingParameterValueset1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; var mappingParameter_1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.mappingParameterType_1, Owner = this.domain, ValueSet = { mappingParameterValueset1 } }; var valueParameterValueset1_1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ActualState = this.actualFinitateSte_on }; var valueParameterValueset1_2 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ActualState = this.actualFinitateSte_off }; var valueParameterValueset1_3 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ActualState = this.actualFinitateSte_standby }; var valueParameter_1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.valueParameterType_1, Owner = this.domain, StateDependence = this.actualFiniteStateList, ValueSet = { valueParameterValueset1_1, valueParameterValueset1_2, valueParameterValueset1_3 } }; this.elementDefinition_1.Parameter.Add(sourceParameter_1); this.elementDefinition_1.Parameter.Add(mappingParameter_1); this.elementDefinition_1.Parameter.Add(valueParameter_1); this.elementDefinition_1.Category.Add(this.elementDefinitionCategory_2); this.iteration.Element.Add(this.elementDefinition_1); //ElementUsages this.elementUsage_1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Name = "reaction wheel 1", ShortName = "RW_1", ElementDefinition = this.elementDefinition_1 }; var sourceParameterOverrideValueset1 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "100" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; var sourceParameterOverride_1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = sourceParameter_1, ValueSet = { sourceParameterOverrideValueset1 } }; this.parameterToStateMapping_1 = new ParameterToStateMapping("100", this.sourceParameterType_1, this.actualFinitateSte_on, ""); this.parameterToStateMapping_2 = new ParameterToStateMapping("100", this.sourceParameterType_1, this.actualFinitateSte_off, ""); this.parameterToStateMappingList = new[] { this.parameterToStateMapping_1, this.parameterToStateMapping_2 }; var mappingParameterOverrideValueset1 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { JsonConvert.SerializeObject(this.parameterToStateMappingList) }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL }; var mappingParameterOverride_1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = mappingParameter_1, ValueSet = { mappingParameterOverrideValueset1 } }; var valueParameterOverrideValueset1_1 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "100" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ParameterValueSet = valueParameterValueset1_1 }; var valueParameterOverrideValueset1_2 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "150" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ParameterValueSet = valueParameterValueset1_2 }; var valueParameterOverrideValueset1_3 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Manual = new ValueArray <string>(new List <string> { "-" }), Reference = new ValueArray <string>(new List <string> { "-" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), Published = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.MANUAL, ParameterValueSet = valueParameterValueset1_3 }; var valueParameterOverride_1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = valueParameter_1, ValueSet = { valueParameterOverrideValueset1_1, valueParameterOverrideValueset1_2, valueParameterOverrideValueset1_3 } }; this.elementUsage_1.ParameterOverride.Add(sourceParameterOverride_1); this.elementUsage_1.ParameterOverride.Add(mappingParameterOverride_1); this.elementUsage_1.ParameterOverride.Add(valueParameterOverride_1); this.rootElementDefinition.ContainedElement.Add(this.elementUsage_1); this.elementUsage_2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Name = "reaction wheel 2", ShortName = "RW_2", ElementDefinition = this.elementDefinition_1 }; this.rootElementDefinition.ContainedElement.Add(this.elementUsage_2); this.elementUsage_3 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Name = "reaction wheel 3", ShortName = "RW_3", ElementDefinition = this.elementDefinition_1 }; this.rootElementDefinition.ContainedElement.Add(this.elementUsage_3); }
public void Setup() { this.npgsqlTransaction = null; this.securityContext = new Mock <ISecurityContext>(); this.iterationService = new Mock <IIterationService>(); this.iterationSetupService = new Mock <IIterationSetupService>(); this.engineeringModelSetupService = new Mock <IEngineeringModelSetupService>(); this.engineeringModelService = new Mock <IEngineeringModelService>(); this.requestUtils = new Mock <IRequestUtils>(); //// edA //// / \ //// euA euB //// / \ //// edB edC //// / \ //// euC euD euE will be added. euE-edD does not throw an exception, but euD-edA does throw //// / \ \ //// edD edA edD this.edD = new ElementDefinition { Iid = Guid.NewGuid() }; this.euE = new ElementUsage { Iid = Guid.NewGuid(), ElementDefinition = this.edD.Iid }; this.euC = new ElementUsage { Iid = Guid.NewGuid(), ElementDefinition = this.edD.Iid }; this.edC = new ElementDefinition { Iid = Guid.NewGuid(), ContainedElement = new List <Guid> { this.euC.Iid } }; this.euB = new ElementUsage { Iid = Guid.NewGuid(), ElementDefinition = this.edC.Iid }; this.edB = new ElementDefinition { Iid = Guid.NewGuid() }; this.euA = new ElementUsage { Iid = Guid.NewGuid(), ElementDefinition = this.edB.Iid }; this.edA = new ElementDefinition { Iid = Guid.NewGuid(), ContainedElement = new List <Guid> { this.euA.Iid, this.euB.Iid } }; this.euD = new ElementUsage { Iid = Guid.NewGuid(), ElementDefinition = this.edA.Iid }; this.elementDefinitionService = new Mock <IElementDefinitionService>(); this.elementDefinitionService .Setup(x => x.Get(this.npgsqlTransaction, It.IsAny <string>(), null, It.IsAny <ISecurityContext>())) .Returns(new List <Thing> { this.edA, this.edB, this.edC, this.edD }); this.elementUsageService = new Mock <IElementUsageService>(); this.elementUsageService .Setup(x => x.Get(this.npgsqlTransaction, It.IsAny <string>(), null, It.IsAny <ISecurityContext>())) .Returns(new List <Thing> { this.euA, this.euB, this.euC, this.euD, this.euE }); this.iterationSetup = new IterationSetup { Iid = Guid.NewGuid() }; this.iteration = new Iteration { Iid = Guid.NewGuid(), Element = new List <Guid> { this.edA.Iid, this.edB.Iid, this.edC.Iid, this.edD.Iid }, TopElement = this.edA.Iid, IterationSetup = this.iterationSetup.Iid }; this.updatedIteration = this.iteration.DeepClone <Iteration>(); this.iterationSetup.IterationIid = this.iteration.Iid; this.engineeringModelSetup = new EngineeringModelSetup { Iid = Guid.NewGuid(), IterationSetup = new List <Guid> { this.iterationSetup.Iid } }; this.engineeringModel = new EngineeringModel { Iid = Guid.NewGuid(), EngineeringModelSetup = this.engineeringModelSetup.Iid }; this.engineeringModelSetup.EngineeringModelIid = this.engineeringModel.Iid; this.sideEffect = new ElementDefinitionSideEffect { ElementDefinitionService = this.elementDefinitionService.Object, ElementUsageService = this.elementUsageService.Object, IterationService = this.iterationService.Object, IterationSetupService = this.iterationSetupService.Object, EngineeringModelSetupService = this.engineeringModelSetupService.Object, EngineeringModelService = this.engineeringModelService.Object, RequestUtils = this.requestUtils.Object }; }
/// <summary> /// Initializes a new instance of the <see cref="SubSystem"/> class /// </summary> /// <param name="definition">The sub-system definition</param> /// <param name="usage">The corresponding <see cref="ElementUsage"/> representing the sub-system</param> public SubSystem(SubSystemDefinition definition, ElementUsage usage) { this.equipments = new List <ElementUsage>(); this.SubSystemDefinition = definition; this.SubSystemElementUsage = usage; }