public void VerifyThatOptionDependentStateDependentParameterValueSetReturnsExpectedModelCode() { var option = new Option(Guid.NewGuid(), null, null); option.ShortName = "option_1"; this.parameter.IsOptionDependent = true; this.parameterValueSet.ActualOption = option; var possibleFiniteStateList = new PossibleFiniteStateList(); var possibleFiniteState = new PossibleFiniteState(); possibleFiniteState.ShortName = "SM"; possibleFiniteStateList.PossibleState.Add(possibleFiniteState); var actualFiniteStateList = new ActualFiniteStateList(); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteState = new ActualFiniteState(); actualFiniteState.PossibleState.Add(possibleFiniteState); actualFiniteStateList.ActualState.Add(actualFiniteState); this.parameter.StateDependence = actualFiniteStateList; this.parameterValueSet.ActualState = actualFiniteState; Assert.AreEqual(@"Sat.m\option_1\SM", this.parameterValueSet.ModelCode(0)); }
public void VerifyThatOrderOfPossibleStatesIsUpdated() { var list = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.iteration.PossibleFiniteStateList.Add(list); var row = new PossibleFiniteStateListRowViewModel(list, this.session.Object, null); var state1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "1" }; var state2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri) { Name = "2" }; list.PossibleState.Add(state1); list.PossibleState.Add(state2); this.rev.SetValue(list, 2); CDPMessageBus.Current.SendObjectChangeEvent(list, EventKind.Updated); Assert.AreEqual(2, row.ContainedRows.Count); Assert.AreEqual("1", ((PossibleFiniteStateRowViewModel)row.ContainedRows.First()).Name); Assert.AreEqual("2", ((PossibleFiniteStateRowViewModel)row.ContainedRows.Last()).Name); list.PossibleState.Move(1, 0); this.rev.SetValue(list, 3); CDPMessageBus.Current.SendObjectChangeEvent(list, EventKind.Updated); Assert.AreEqual("2", ((PossibleFiniteStateRowViewModel)row.ContainedRows.First()).Name); Assert.AreEqual("1", ((PossibleFiniteStateRowViewModel)row.ContainedRows.Last()).Name); }
public void Verify_that_ExecuteBatchUpdateParameterCommand_works_as_expected() { var possibleList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); var ps = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); possibleList.PossibleState.Add(ps); this.iteration.PossibleFiniteStateList.Add(possibleList); var actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); actualList.PossibleFiniteStateList.Add(possibleList); var astate = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); astate.PossibleState.Add(ps); actualList.ActualState.Add(astate); this.iteration.ActualFiniteStateList.Add(actualList); var dialogResult = new CDP4EngineeringModel.ViewModels.Dialogs.CategoryDomainParameterTypeSelectorResult(true, false, Enumerable.Empty <ParameterType>(), Enumerable.Empty <Category>(), Enumerable.Empty <DomainOfExpertise>()); this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <IDialogViewModel>())).Returns(dialogResult); var vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, this.dialogNavigationService.Object, null, this.parameterActualFiniteStateListApplicationBatchService.Object); vm.SelectedThing = new ActualFiniteStateListRowViewModel(actualList, this.session.Object, null); vm.BatchUpdateParameterCommand.Execute(null); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()), Times.Exactly(1)); this.parameterActualFiniteStateListApplicationBatchService.Verify(x => x.Update(this.session.Object, this.iteration, It.IsAny <ActualFiniteStateList>(), false, It.IsAny <IEnumerable <Category> >(), It.IsAny <IEnumerable <DomainOfExpertise> >(), It.IsAny <IEnumerable <ParameterType> >()), Times.Exactly(1)); }
public void SetUp() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.possibleFiniteStateList_1 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteState_1_1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteState_1_2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteStateList_1.PossibleState.Add(this.possibleFiniteState_1_1); this.possibleFiniteStateList_1.PossibleState.Add(this.possibleFiniteState_1_2); this.possibleFiniteStateList_2 = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteState_2_1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteState_2_2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.possibleFiniteStateList_2.PossibleState.Add(this.possibleFiniteState_2_1); this.possibleFiniteStateList_2.PossibleState.Add(this.possibleFiniteState_2_2); this.actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteStateList.PossibleFiniteStateList.Insert(1, this.possibleFiniteStateList_1); this.actualFiniteState_1 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteState_1.PossibleState.Add(this.possibleFiniteState_1_1); this.actualFiniteState_2 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteState_2.PossibleState.Add(this.possibleFiniteState_1_2); this.actualFiniteState_3 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteState_3.PossibleState.Add(this.possibleFiniteState_2_1); this.actualFiniteState_4 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualFiniteState_4.PossibleState.Add(this.possibleFiniteState_2_2); this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_1); this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_2); this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_3); this.actualFiniteStateList.ActualState.Add(this.actualFiniteState_4); this.comparer = new ActualFiniteStateComparer(); }
public void Setup() { this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.owner = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.statelist = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri) { Owner = this.owner }; this.model.Iteration.Add(this.iteration); this.iteration.PossibleFiniteStateList.Add(this.statelist); this.cache.TryAdd(new CacheKey(this.statelist.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.statelist)); 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 VerifyThatSetDefaultWorks() { var statelist = new PossibleFiniteStateList { Name = "name", ShortName = "shortname" }; var state = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); statelist.PossibleState.Add(state); var containerClone = this.iteration.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); var transaction = new ThingTransaction(transactionContext, containerClone); var vm = new PossibleFiniteStateListDialogViewModel(statelist, transaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, containerClone); vm.SelectedPossibleState = vm.PossibleState.Single(); vm.SetDefaultStateCommand.Execute(null); Assert.IsTrue(((PossibleFiniteStateRowViewModel)vm.SelectedPossibleState).IsDefault); Assert.AreSame(vm.SelectedDefaultState, state); }
public void Setup() { this.model = new EngineeringModel(Guid.NewGuid(), 0); this.iteration = new Iteration(Guid.NewGuid(), 0); this.statelist = new PossibleFiniteStateList(Guid.NewGuid(), 0) { IterationContainerId = this.iteration.Iid }; this.state = new PossibleFiniteState(Guid.NewGuid(), 0) { IterationContainerId = this.iteration.Iid }; this.model.Iteration.Add(this.iteration.Iid); this.iteration.PossibleFiniteStateList.Add(this.statelist.Iid); this.statelist.PossibleState.Add(new OrderedItem { K = 1, V = this.state.Iid }); this.assembler = new Assembler(this.uri); this.session = new Mock <ISession>(); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.pocoModel = new Poco.EngineeringModel(this.model.Iid, this.assembler.Cache, this.uri); this.pocoIt = new Poco.Iteration(this.iteration.Iid, this.assembler.Cache, this.uri); this.pocoStateList = new Poco.PossibleFiniteStateList(this.statelist.Iid, this.assembler.Cache, this.uri); this.pocoState = new Poco.PossibleFiniteState(this.state.Iid, this.assembler.Cache, this.uri); this.pocoModel.Iteration.Add(pocoIt); this.pocoIt.PossibleFiniteStateList.Add(pocoStateList); this.pocoStateList.PossibleState.Add(pocoState); }
public void OrderedItemListIsClonedCorrectlyTest() { var pfs1 = new PossibleFiniteState(Guid.NewGuid(), null, null); pfs1.Name = "state1"; pfs1.ShortName = "s1"; var pfs2 = new PossibleFiniteState(Guid.NewGuid(), null, null); pfs2.Name = "state1"; pfs2.ShortName = "s1"; var pfsList = new PossibleFiniteStateList(Guid.NewGuid(), null, null); pfsList.Name = "PossibleFiniteStateList1"; pfsList.ShortName = "PFSL1"; pfsList.PossibleState.Add(pfs1); pfsList.PossibleState.Add(pfs2); var dtoOrderedItemListOriginal = pfsList.PossibleState.ToDtoOrderedItemList().ToList(); var pfsListClone = pfsList.Clone(true); var dtoOrderedItemListClone = pfsListClone.PossibleState.ToDtoOrderedItemList().ToList(); Assert.AreEqual(dtoOrderedItemListOriginal[0].K, dtoOrderedItemListClone[0].K); Assert.AreEqual(dtoOrderedItemListOriginal[0].V, dtoOrderedItemListClone[0].V); Assert.AreEqual(dtoOrderedItemListOriginal[1].K, dtoOrderedItemListClone[1].K); Assert.AreEqual(dtoOrderedItemListOriginal[1].V, dtoOrderedItemListClone[1].V); }
public void VerifyThatStateDependentParameterOverrideValueSetReturnsExpectedModelCode() { var possibleFiniteStateList = new PossibleFiniteStateList(); var possibleFiniteState = new PossibleFiniteState(); possibleFiniteState.ShortName = "SM"; possibleFiniteStateList.PossibleState.Add(possibleFiniteState); var actualFiniteStateList = new ActualFiniteStateList(); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteState = new ActualFiniteState(); actualFiniteState.PossibleState.Add(possibleFiniteState); actualFiniteStateList.ActualState.Add(actualFiniteState); this.scalarParameter.StateDependence = actualFiniteStateList; var parameterValueSet = this.scalarParameter.ValueSet.Single(); parameterValueSet.ActualState = actualFiniteState; var parameterOverride = new ParameterOverride(); parameterOverride.Parameter = this.scalarParameter; this.elementUsage.ParameterOverride.Add(parameterOverride); var parameterOverrideValueSet = new ParameterOverrideValueSet(); parameterOverrideValueSet.ParameterValueSet = parameterValueSet; parameterOverride.ValueSet.Add(parameterOverrideValueSet); parameterOverrideValueSet.ParameterValueSet = parameterValueSet; Assert.AreEqual(@"Sat.battery_1.l\SM", parameterOverrideValueSet.ModelCode(0)); }
public void VerifyThatTreeIsCorrectlyBuilt() { var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.iteration.PossibleFiniteStateList.Add(possibleFiniteStateList); var possibleFiniteState = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); possibleFiniteStateList.PossibleState.Add(possibleFiniteState); var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); this.iteration.ActualFiniteStateList.Add(actualFiniteStateList); var row = new ActualFiniteStateListRowViewModel(actualFiniteStateList, this.session.Object, null); Assert.IsEmpty(row.ContainedRows); var state = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); state.PossibleState.Add(possibleFiniteState); actualFiniteStateList.ActualState.Add(state); this.rev.SetValue(actualFiniteStateList, 2); CDPMessageBus.Current.SendObjectChangeEvent(actualFiniteStateList, EventKind.Updated); var staterow = (ActualFiniteStateRowViewModel)row.ContainedRows.SingleOrDefault(); Assert.IsNotNull(staterow); }
public void VerifyThatPropertiesAreSet() { var statelist = new PossibleFiniteStateList { Name = "name", ShortName = "shortname" }; var containerClone = this.iteration.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); var transaction = new ThingTransaction(transactionContext, containerClone); var vm = new PossibleFiniteStateListDialogViewModel(statelist, transaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, containerClone); Assert.AreEqual(statelist.Name, vm.Name); Assert.AreEqual(statelist.ShortName, vm.ShortName); Assert.AreEqual(1, vm.PossibleOwner.Count); Assert.AreEqual(1, vm.PossibleCategory.Count); Assert.IsFalse(vm.OkCanExecute); statelist.PossibleState.Add(new PossibleFiniteState(Guid.NewGuid(), null, null)); statelist.DefaultState = statelist.PossibleState.First(); vm = new PossibleFiniteStateListDialogViewModel(statelist, transaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, containerClone); Assert.AreEqual(1, vm.PossibleState.Count); Assert.AreEqual(statelist.DefaultState, vm.SelectedDefaultState); }
public void TestGetOwner() { var thing = new PossibleFiniteState(); var list = new PossibleFiniteStateList(); list.Owner = new DomainOfExpertise(); list.PossibleState.Add(thing); Assert.IsTrue(ReferenceEquals(list.Owner, thing.Owner)); }
public void VerifyIsDefault() { var thing = new PossibleFiniteState(); var list = new PossibleFiniteStateList(); list.PossibleState.Add(thing); Assert.IsFalse(thing.IsDefault); list.DefaultState = thing; Assert.IsTrue(thing.IsDefault); }
private void SetupFiniteStates() { this.ActualPossibleFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri); var possibleStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri) { ShortName = "actualFiniteStateListTest" }; var possibleState1 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "1" }; var possibleState2 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "2" }; var possibleState3 = new PossibleFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { Name = "3" }; possibleStateList.PossibleState.Add(possibleState1); possibleStateList.PossibleState.Add(possibleState2); possibleStateList.PossibleState.Add(possibleState3); this.Iteration.PossibleFiniteStateList.Add(possibleStateList); this.ActualPossibleFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), this.Assembler.Cache, this.uri); var actualState1 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { possibleState1 } }; var actualState2 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { possibleState2 } }; var actualState3 = new ActualFiniteState(Guid.NewGuid(), this.Assembler.Cache, this.uri) { PossibleState = new List <PossibleFiniteState> { possibleState3 } }; this.ActualPossibleFiniteStateList.ActualState.Add(actualState1); this.ActualPossibleFiniteStateList.ActualState.Add(actualState2); this.ActualPossibleFiniteStateList.ActualState.Add(actualState3); this.ActualPossibleFiniteStateList.PossibleFiniteStateList.Add(possibleStateList); this.Iteration.ActualFiniteStateList.Add(this.ActualPossibleFiniteStateList); }
public void VerifyThatResolveCopyWorksWithOrderedItem() { var pfsl = new PossibleFiniteStateList(Guid.NewGuid(), 1) { Name = "test", ShortName = "test", Owner = Guid.NewGuid() }; pfsl.Category.Add(Guid.NewGuid()); var ps1 = new PossibleFiniteState(Guid.NewGuid(), 1) { Name = "ps1", ShortName = "ps1" }; var ps2 = new PossibleFiniteState(Guid.NewGuid(), 1) { Name = "ps2", ShortName = "ps2" }; pfsl.PossibleState.Add(new OrderedItem { K = 0, V = ps1.Iid }); pfsl.PossibleState.Add(new OrderedItem { K = 2, V = ps2.Iid }); var copypfsl = new PossibleFiniteStateList(Guid.NewGuid(), 1); var copyps1 = new PossibleFiniteState(Guid.NewGuid(), 1); var copyps2 = new PossibleFiniteState(Guid.NewGuid(), 1); var dictionary = new Dictionary <CDP4Common.DTO.Thing, CDP4Common.DTO.Thing>(); dictionary.Add(pfsl, copypfsl); dictionary.Add(ps1, copyps1); dictionary.Add(ps2, copyps2); copypfsl.ResolveCopy(pfsl, dictionary); copyps1.ResolveCopy(ps1, dictionary); copyps2.ResolveCopy(ps2, dictionary); Assert.That(copypfsl.PossibleState.Any(ps => ps.V.ToString() == copyps1.Iid.ToString()), Is.True); Assert.That(copypfsl.PossibleState.Any(ps => ps.V.ToString() == copyps2.Iid.ToString()), Is.True); Assert.That(copypfsl.Name, Is.EqualTo(pfsl.Name)); Assert.That(copypfsl.Owner, Is.EqualTo(pfsl.Owner)); Assert.That(copypfsl.Category.Contains(pfsl.Category.Single()), Is.True); }
/// <summary> /// Posts a predefined <see cref="PossibleFiniteStateList"/> /// </summary> private void PostPossibleFiniteStateList() { if (this.session.OpenIterations.Count == 0) { Console.WriteLine("At first an iteration should be opened"); return; } var iteration = this.session.OpenIterations.Keys.First(); if (iteration != null) { var iterationClone = iteration.Clone(false); var pfs1 = new PossibleFiniteState(Guid.NewGuid(), this.session.Assembler.Cache, this.uri) { Name = "state1", ShortName = "s1" }; var pfs2 = new PossibleFiniteState(Guid.NewGuid(), this.session.Assembler.Cache, this.uri) { Name = "state2", ShortName = "s2" }; var pfsList = new PossibleFiniteStateList(Guid.NewGuid(), this.session.Assembler.Cache, this.uri) { Name = "PossibleFiniteStateList1", ShortName = "PFSL1" }; this.session.OpenIterations.TryGetValue(iteration, out var tuple); var domainOfExpertise = tuple.Item1; pfsList.Owner = domainOfExpertise; var transaction = new ThingTransaction( TransactionContextResolver.ResolveContext(iterationClone), iterationClone); transaction.Create(pfsList, iterationClone); transaction.Create(pfs1, pfsList); transaction.Create(pfs2, pfsList); this.session.Write(transaction.FinalizeTransaction()).GetAwaiter().GetResult(); this.PrintCacheCount(); this.PrintCommands(); } }
public void VerifyThatContextMenuPopulated() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); var possibleList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); var ps = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); possibleList.PossibleState.Add(ps); this.iteration.PossibleFiniteStateList.Add(possibleList); var actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); actualList.PossibleFiniteStateList.Add(possibleList); var astate = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); astate.PossibleState.Add(ps); actualList.ActualState.Add(astate); this.iteration.ActualFiniteStateList.Add(actualList); var viewmodel = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null); // no row selected viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(2, viewmodel.ContextMenu.Count); // posible state row selected var pslFolder = viewmodel.FiniteStateList.First(); var psRow = pslFolder.ContainedRows.First().ContainedRows.First(); viewmodel.SelectedThing = psRow; viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(8, viewmodel.ContextMenu.Count); // execute set default Assert.IsTrue(viewmodel.CanSetAsDefault); viewmodel.SetDefaultStateCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); }
public void VerifyThatContainedThingsDeepReturnsExceptedResult() { var iteration = new Iteration(); var elementDefinition1 = new ElementDefinition(); var elementDefinition2 = new ElementDefinition(); var alias1 = new Alias(); var alias2 = new Alias(); var possibleFiniteStateList1 = new PossibleFiniteStateList(); var possibleFiniteStateList2 = new PossibleFiniteStateList(); var possibleFiniteState1_1 = new PossibleFiniteState(); var possibleFiniteState1_2 = new PossibleFiniteState(); var possibleFiniteState2_1 = new PossibleFiniteState(); var possibleFiniteState2_2 = new PossibleFiniteState(); iteration.Element.Add(elementDefinition1); iteration.Element.Add(elementDefinition2); elementDefinition1.Alias.Add(alias1); elementDefinition1.Alias.Add(alias2); iteration.PossibleFiniteStateList.Add(possibleFiniteStateList1); iteration.PossibleFiniteStateList.Add(possibleFiniteStateList2); possibleFiniteStateList1.PossibleState.Add(possibleFiniteState1_1); possibleFiniteStateList1.PossibleState.Add(possibleFiniteState1_2); possibleFiniteStateList2.PossibleState.Add(possibleFiniteState2_1); possibleFiniteStateList2.PossibleState.Add(possibleFiniteState2_2); var things = iteration.QueryContainedThingsDeep(); Assert.AreEqual(11, things.Count()); CollectionAssert.Contains(things, iteration); CollectionAssert.Contains(things, elementDefinition1); CollectionAssert.Contains(things, elementDefinition2); CollectionAssert.Contains(things, alias1); CollectionAssert.Contains(things, alias2); CollectionAssert.Contains(things, possibleFiniteStateList1); CollectionAssert.Contains(things, possibleFiniteStateList2); CollectionAssert.Contains(things, possibleFiniteState1_1); CollectionAssert.Contains(things, possibleFiniteState1_2); CollectionAssert.Contains(things, possibleFiniteState2_1); CollectionAssert.Contains(things, possibleFiniteState2_2); }
public void VerifyThatTreeIsBuiltCorrectly() { var viewmodel = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null, null); Assert.IsNotEmpty(viewmodel.FiniteStateList); var possibleList = new PossibleFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.iteration.PossibleFiniteStateList.Add(possibleList); this.rev.SetValue(this.iteration, 1); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); var possibleListRow = viewmodel.FiniteStateList.FirstOrDefault(); Assert.IsNotNull(possibleListRow); Assert.IsTrue(possibleListRow.ContainedRows.Select(x => x.Thing).Contains(possibleList)); this.iteration.PossibleFiniteStateList.Clear(); this.rev.SetValue(this.iteration, 2); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.IsNotEmpty(viewmodel.FiniteStateList); var actualList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.rev.SetValue(this.iteration, 3); this.iteration.ActualFiniteStateList.Add(actualList); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); var actualListRow = viewmodel.FiniteStateList.Last(); Assert.IsNotNull(actualListRow); Assert.IsNotEmpty(actualListRow.ContainedRows); this.iteration.PossibleFiniteStateList.Add(possibleList); this.iteration.ActualFiniteStateList.Remove(actualList); this.rev.SetValue(this.iteration, 4); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.AreEqual(2, viewmodel.FiniteStateList.Count); Assert.AreSame(possibleListRow, viewmodel.FiniteStateList.First()); }
public void VerifyThatStateDependentParameterValueSetReturnsExpectedModelCode() { var possibleFiniteStateList = new PossibleFiniteStateList(); var possibleFiniteState = new PossibleFiniteState(); possibleFiniteState.ShortName = "SM"; possibleFiniteStateList.PossibleState.Add(possibleFiniteState); var actualFiniteStateList = new ActualFiniteStateList(); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteState = new ActualFiniteState(); actualFiniteState.PossibleState.Add(possibleFiniteState); actualFiniteStateList.ActualState.Add(actualFiniteState); this.parameter.StateDependence = actualFiniteStateList; this.parameterValueSet.ActualState = actualFiniteState; Assert.AreEqual(@"Sat.m\SM", this.parameterValueSet.ModelCode(0)); }
public void SetUp() { this.iteration = new Iteration(Guid.NewGuid(), null, null); this.optiona = new Option(Guid.NewGuid(), null, null) { Name = "option a", ShortName = "optionb" }; this.optionb = new Option(Guid.NewGuid(), null, null) { Name = "option b", ShortName = "optionb" }; this.iteration.Option.Add(this.optionb); this.iteration.Option.Add(this.optiona); var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleFiniteStatea = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "state a", ShortName = "statea" }; var possibleFiniteStateb = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "state b", ShortName = "stateb" }; possibleFiniteStateList.PossibleState.Add(possibleFiniteStateb); possibleFiniteStateList.PossibleState.Add(possibleFiniteStatea); this.iteration.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), null, null); this.actualFiniteStatea = new ActualFiniteState(Guid.NewGuid(), null, null); this.actualFiniteStatea.PossibleState.Add(possibleFiniteStatea); this.actualFiniteStateb = new ActualFiniteState(Guid.NewGuid(), null, null); this.actualFiniteStateb.PossibleState.Add(possibleFiniteStateb); actualFiniteStateList.ActualState.Add(this.actualFiniteStateb); actualFiniteStateList.ActualState.Add(this.actualFiniteStatea); this.iteration.ActualFiniteStateList.Add(actualFiniteStateList); }
/// <summary> /// Serialize the <see cref="PossibleFiniteStateList"/> /// </summary> /// <param name="possibleFiniteStateList">The <see cref="PossibleFiniteStateList"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(PossibleFiniteStateList possibleFiniteStateList) { var jsonObject = new JObject(); jsonObject.Add("alias", this.PropertySerializerMap["alias"](possibleFiniteStateList.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("category", this.PropertySerializerMap["category"](possibleFiniteStateList.Category.OrderBy(x => x, this.guidComparer))); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), possibleFiniteStateList.ClassKind))); jsonObject.Add("defaultState", this.PropertySerializerMap["defaultState"](possibleFiniteStateList.DefaultState)); jsonObject.Add("definition", this.PropertySerializerMap["definition"](possibleFiniteStateList.Definition.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](possibleFiniteStateList.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](possibleFiniteStateList.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](possibleFiniteStateList.HyperLink.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](possibleFiniteStateList.Iid)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](possibleFiniteStateList.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](possibleFiniteStateList.Name)); jsonObject.Add("owner", this.PropertySerializerMap["owner"](possibleFiniteStateList.Owner)); jsonObject.Add("possibleState", this.PropertySerializerMap["possibleState"](possibleFiniteStateList.PossibleState.OrderBy(x => x, this.orderedItemComparer))); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](possibleFiniteStateList.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](possibleFiniteStateList.ShortName)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](possibleFiniteStateList.ThingPreference)); return(jsonObject); }
public void Setup() { this.actualFiniteState = new ActualFiniteState(Guid.NewGuid(), null, null); this.actualList = new ActualFiniteStateList(Guid.NewGuid(), null, null); this.actualList.Owner = new DomainOfExpertise(Guid.NewGuid(), null, null); this.possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), null, null); this.possibleList2 = new PossibleFiniteStateList(Guid.NewGuid(), null, null); this.possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate1", ShortName = "1" }; this.possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate2", ShortName = "2" }; this.possibleList1.PossibleState.Add(this.possibleState1); this.possibleList2.PossibleState.Add(this.possibleState2); this.actualFiniteState.PossibleState.Add(this.possibleState1); this.actualFiniteState.PossibleState.Add(this.possibleState2); this.actualList.PossibleFiniteStateList.Add(this.possibleList1); this.actualList.PossibleFiniteStateList.Add(this.possibleList2); this.iteration = new Iteration(Guid.NewGuid(), null, null); this.model = new EngineeringModel(Guid.NewGuid(), null, null); this.model.Iteration.Add(this.iteration); this.iteration.ActualFiniteStateList.Add(this.actualList); this.iteration.PossibleFiniteStateList.Add(this.possibleList1); this.iteration.PossibleFiniteStateList.Add(this.possibleList2); this.actualList.ActualState.Add(this.actualFiniteState); }
public void VerifyThatContainmentCanBeResolved() { ElementDefinition elementDefinition; ElementDefinition elementDefinition2; Iteration iteration; var elementDefinitionId = Guid.NewGuid(); var elementDefinitionId2 = Guid.NewGuid(); var iterationId = Guid.NewGuid(); elementDefinition = new ElementDefinition(elementDefinitionId, 1); elementDefinition2 = new ElementDefinition(elementDefinitionId2, 1); iteration = new Iteration(iterationId, 1); iteration.Element.Add(elementDefinitionId); Assert.IsTrue(iteration.Contains(elementDefinition)); Assert.IsFalse(iteration.Contains(elementDefinition2)); // check ordered items var state1 = new PossibleFiniteState(Guid.NewGuid(), 1); var state2 = new PossibleFiniteState(Guid.NewGuid(), 1); var state3 = new PossibleFiniteState(Guid.NewGuid(), 1); var list = new PossibleFiniteStateList(Guid.NewGuid(), 1); list.PossibleState.Add(new OrderedItem { K = 1, V = state1.Iid }); list.PossibleState.Add(new OrderedItem { K = 100, V = state2.Iid }); Assert.That(list.Contains(state1), Is.True); Assert.That(list.Contains(state2), Is.True); Assert.That(list.Contains(state3), Is.False); }
public void Setup() { this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.thingDialognavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.stateList = new ActualFiniteStateList(Guid.NewGuid(), null, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), null, this.uri) { Name = "state1" }; this.state2 = new PossibleFiniteState(Guid.NewGuid(), null, this.uri) { Name = "state2" }; this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, this.uri); this.posStateList.PossibleState.Add(this.state1); this.posStateList.PossibleState.Add(this.state2); this.posStateList.DefaultState = this.state1; this.actualState1 = new ActualFiniteState(Guid.NewGuid(), null, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }; this.actualState2 = new ActualFiniteState(Guid.NewGuid(), null, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.MANDATORY }; this.stateList.ActualState.Add(this.actualState1); this.stateList.ActualState.Add(this.actualState2); this.stateList.PossibleFiniteStateList.Add(this.posStateList); this.option1 = new Option(Guid.NewGuid(), null, this.uri) { Name = "option1" }; this.option2 = new Option(Guid.NewGuid(), null, this.uri) { Name = "option2" }; this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri) { Name = "PTName", ShortName = "PTShortName" }; this.enum1 = new EnumerationValueDefinition(Guid.NewGuid(), null, this.uri) { Name = "enum1" }; this.enum2 = new EnumerationValueDefinition(Guid.NewGuid(), null, this.uri) { Name = "enum2" }; this.enumPt = new EnumerationParameterType(Guid.NewGuid(), null, this.uri); this.enumPt.ValueDefinition.Add(this.enum1); this.enumPt.ValueDefinition.Add(this.enum2); this.cptType = new CompoundParameterType(Guid.NewGuid(), null, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType, ShortName = "c1" }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), null, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.enumPt, ShortName = "c2" }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri) { Name = "active", ShortName = "active" }; this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri) { Name = "other", ShortName = "other" }; this.parameter = new Parameter(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain, ParameterType = this.qqParamType }; this.cptParameter = new Parameter(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain, ParameterType = this.cptType, IsOptionDependent = true, StateDependence = this.stateList }; this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.First())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option1, this.stateList.ActualState.Last())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.First())); this.cptParameter.ValueSet.Add(this.GetNewParameterValueSet(this.option2, this.stateList.ActualState.Last())); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, this.uri) { Owner = this.activeDomain }; this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), null, this.uri); this.elementUsage1 = new ElementUsage(Guid.NewGuid(), null, this.uri) { ElementDefinition = this.elementDefinitionForUsage1 }; this.elementDefinition.ContainedElement.Add(this.elementUsage1); this.elementDefinitionForUsage1.Parameter.Add(this.parameter); this.elementDefinitionForUsage1.Parameter.Add(this.cptParameter); this.iteration = new Iteration(Guid.NewGuid(), null, this.uri); this.iteration.Element.Add(this.elementDefinition); this.iteration.Element.Add(this.elementDefinitionForUsage1); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.model = new EngineeringModel(Guid.NewGuid(), null, this.uri); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), null, this.uri) { GivenName = "test", Surname = "test" }; this.participant = new Participant(Guid.NewGuid(), null, this.uri) { Person = this.person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(this.person); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); this.modelsetup.Participant.Add(this.participant); this.model.EngineeringModelSetup = this.modelsetup; this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.obfuscationService = new Mock <IObfuscationService>(); 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; }
public void VerifyThatActualFiniteStateKindIsUpdatedOnNewDefault() { var model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); var iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); var possibleList2 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); var possibleList3 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps11 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps12 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps21 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps22 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps31 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); var ps32 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); possibleList1.PossibleState.Add(ps11); possibleList1.PossibleState.Add(ps12); possibleList2.PossibleState.Add(ps21); possibleList2.PossibleState.Add(ps22); possibleList3.PossibleState.Add(ps31); possibleList3.PossibleState.Add(ps32); var actualList1 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); var actualList2 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri); actualList1.PossibleFiniteStateList.Add(possibleList1); actualList1.PossibleFiniteStateList.Add(possibleList2); var as11 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as11.PossibleState.Add(ps11); as11.PossibleState.Add(ps21); var as12 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as12.PossibleState.Add(ps11); as12.PossibleState.Add(ps22); var as13 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as13.PossibleState.Add(ps12); as13.PossibleState.Add(ps21); var as14 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as14.PossibleState.Add(ps12); as14.PossibleState.Add(ps22); actualList1.ActualState.Add(as11); actualList1.ActualState.Add(as12); actualList1.ActualState.Add(as13); actualList1.ActualState.Add(as14); actualList2.PossibleFiniteStateList.Add(possibleList2); actualList2.PossibleFiniteStateList.Add(possibleList3); var as21 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as21.PossibleState.Add(ps21); as21.PossibleState.Add(ps31); var as22 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as22.PossibleState.Add(ps21); as22.PossibleState.Add(ps32); var as23 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as23.PossibleState.Add(ps22); as23.PossibleState.Add(ps31); var as24 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri); as24.PossibleState.Add(ps22); as24.PossibleState.Add(ps32); actualList2.ActualState.Add(as21); actualList2.ActualState.Add(as22); actualList2.ActualState.Add(as23); actualList2.ActualState.Add(as24); model.Iteration.Add(iteration); iteration.PossibleFiniteStateList.Add(possibleList1); iteration.PossibleFiniteStateList.Add(possibleList2); iteration.PossibleFiniteStateList.Add(possibleList3); iteration.ActualFiniteStateList.Add(actualList1); iteration.ActualFiniteStateList.Add(actualList2); this.assembler.Cache.TryAdd(new CacheKey(model.Iid, null), new Lazy <Thing>(() => model)); this.assembler.Cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration)); this.assembler.Cache.TryAdd(new CacheKey(possibleList1.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList1)); this.assembler.Cache.TryAdd(new CacheKey(possibleList2.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList2)); this.assembler.Cache.TryAdd(new CacheKey(possibleList3.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList3)); this.assembler.Cache.TryAdd(new CacheKey(ps11.Iid, iteration.Iid), new Lazy <Thing>(() => ps11)); this.assembler.Cache.TryAdd(new CacheKey(ps12.Iid, iteration.Iid), new Lazy <Thing>(() => ps12)); this.assembler.Cache.TryAdd(new CacheKey(ps21.Iid, iteration.Iid), new Lazy <Thing>(() => ps21)); this.assembler.Cache.TryAdd(new CacheKey(ps22.Iid, iteration.Iid), new Lazy <Thing>(() => ps22)); this.assembler.Cache.TryAdd(new CacheKey(ps31.Iid, iteration.Iid), new Lazy <Thing>(() => ps31)); this.assembler.Cache.TryAdd(new CacheKey(ps32.Iid, iteration.Iid), new Lazy <Thing>(() => ps32)); this.assembler.Cache.TryAdd(new CacheKey(actualList1.Iid, iteration.Iid), new Lazy <Thing>(() => actualList1)); this.assembler.Cache.TryAdd(new CacheKey(actualList2.Iid, iteration.Iid), new Lazy <Thing>(() => actualList2)); this.assembler.Cache.TryAdd(new CacheKey(as11.Iid, iteration.Iid), new Lazy <Thing>(() => as11)); this.assembler.Cache.TryAdd(new CacheKey(as12.Iid, iteration.Iid), new Lazy <Thing>(() => as12)); this.assembler.Cache.TryAdd(new CacheKey(as13.Iid, iteration.Iid), new Lazy <Thing>(() => as13)); this.assembler.Cache.TryAdd(new CacheKey(as14.Iid, iteration.Iid), new Lazy <Thing>(() => as14)); this.assembler.Cache.TryAdd(new CacheKey(as21.Iid, iteration.Iid), new Lazy <Thing>(() => as21)); this.assembler.Cache.TryAdd(new CacheKey(as22.Iid, iteration.Iid), new Lazy <Thing>(() => as22)); this.assembler.Cache.TryAdd(new CacheKey(as23.Iid, iteration.Iid), new Lazy <Thing>(() => as23)); this.assembler.Cache.TryAdd(new CacheKey(as24.Iid, iteration.Iid), new Lazy <Thing>(() => as24)); possibleList1.DefaultState = ps11; as11.Kind = ActualFiniteStateKind.FORBIDDEN; var transactionContext = TransactionContextResolver.ResolveContext(iteration); var context = transactionContext.ContextRoute(); var operationContainer = new OperationContainer(context, model.RevisionNumber); var original = possibleList2.ToDto(); var modify = (CDP4Common.DTO.PossibleFiniteStateList)possibleList2.ToDto(); modify.DefaultState = ps21.Iid; operationContainer.AddOperation(new Operation(original, modify, OperationKind.Update)); Assert.AreEqual(1, operationContainer.Operations.Count()); var modifier = new OperationModifier(this.session.Object); modifier.ModifyOperationContainer(operationContainer); Assert.AreEqual(2, operationContainer.Operations.Count()); var addedOperation = operationContainer.Operations.Last(); var originalActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.OriginalThing; var modifiedActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.ModifiedThing; Assert.AreEqual(as11.Iid, originalActualState.Iid); Assert.AreEqual(ActualFiniteStateKind.MANDATORY, modifiedActualState.Kind); Assert.AreEqual(ActualFiniteStateKind.FORBIDDEN, originalActualState.Kind); }
/// <summary> /// Persist the <see cref="PossibleFiniteStateList"/> 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="possibleFiniteStateList"> /// The <see cref="PossibleFiniteStateList"/> instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool UpsertContainment(NpgsqlTransaction transaction, string partition, PossibleFiniteStateList possibleFiniteStateList) { var results = new List <bool>(); foreach (var alias in this.ResolveFromRequestCache(possibleFiniteStateList.Alias)) { results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, possibleFiniteStateList)); } foreach (var definition in this.ResolveFromRequestCache(possibleFiniteStateList.Definition)) { results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, possibleFiniteStateList)); } foreach (var hyperLink in this.ResolveFromRequestCache(possibleFiniteStateList.HyperLink)) { results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, possibleFiniteStateList)); } foreach (var possibleState in this.ResolveFromRequestCache(possibleFiniteStateList.PossibleState)) { results.Add(this.PossibleStateService.UpsertConcept(transaction, partition, (PossibleFiniteState)possibleState.V, possibleFiniteStateList, possibleState.K)); } return(results.All(x => x)); }
public void Setup() { this.securityContext = new Mock <ISecurityContext>(); this.actualFiniteStateListService = new Mock <IActualFiniteStateListService>(); this.actualFiniteStateService = new Mock <IActualFiniteStateService>(); this.possibleFiniteStateListslService = new Mock <IPossibleFiniteStateListService>(); this.parameterValueSetService = new Mock <IParameterValueSetService>(); this.parameterOverrideValueSetService = new Mock <IParameterOverrideValueSetService>(); this.parameterService = new Mock <IParameterService>(); this.parameterOverrideService = new Mock <IParameterOverrideService>(); this.parameterSubscriptionService = new Mock <IParameterSubscriptionService>(); this.parameterSubscriptionValueSetService = new Mock <IParameterSubscriptionValueSetService>(); this.iterationService = new Mock <IIterationService>(); this.defaultValueArrayFactory = new Mock <IDefaultValueArrayFactory>(); this.parameterUpdateService = new StateDependentParameterUpdateService(); this.finiteStateLogicService = new FiniteStateLogicService(); this.parameterUpdateService.ParameterValueSetService = this.parameterValueSetService.Object; this.parameterUpdateService.ParameterOverrideValueSetService = this.parameterOverrideValueSetService.Object; this.parameterUpdateService.ParameterService = this.parameterService.Object; this.parameterUpdateService.ParameterOverrideService = this.parameterOverrideService.Object; this.parameterUpdateService.ParameterSubscriptionService = this.parameterSubscriptionService.Object; this.parameterUpdateService.ParameterSubscriptionValueSetService = this.parameterSubscriptionValueSetService.Object; this.iteration = new Iteration(Guid.NewGuid(), 1); this.option1 = new Option(Guid.NewGuid(), 1); this.iteration.Option.Add(new OrderedItem { K = 1, V = this.option1.Iid.ToString() }); this.psl1 = new PossibleFiniteStateList(Guid.NewGuid(), 1); this.psl2 = new PossibleFiniteStateList(Guid.NewGuid(), 1); this.ps11 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps12 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps21 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps22 = new PossibleFiniteState(Guid.NewGuid(), 1); this.asl1 = new ActualFiniteStateList(Guid.NewGuid(), 1); this.asl2 = new ActualFiniteStateList(Guid.NewGuid(), 1); this.iteration.PossibleFiniteStateList.Add(this.psl1.Iid); this.iteration.PossibleFiniteStateList.Add(this.psl2.Iid); this.iteration.ActualFiniteStateList.Add(this.asl1.Iid); this.iteration.ActualFiniteStateList.Add(this.asl2.Iid); this.psl1.PossibleState.Add(new OrderedItem { K = 1, V = this.ps11.Iid.ToString() }); this.psl1.PossibleState.Add(new OrderedItem { K = 2, V = this.ps12.Iid.ToString() }); this.psl2.PossibleState.Add(new OrderedItem { K = 1, V = this.ps21.Iid.ToString() }); this.psl2.PossibleState.Add(new OrderedItem { K = 2, V = this.ps22.Iid.ToString() }); this.asl1.PossibleFiniteStateList.Add(new OrderedItem { K = 1, V = this.psl1.Iid.ToString() }); this.asl1.PossibleFiniteStateList.Add(new OrderedItem { K = 2, V = this.psl2.Iid.ToString() }); // initializes actual states actual states this.as11 = new ActualFiniteState(Guid.NewGuid(), 1); this.as11.PossibleState.Add(this.ps11.Iid); this.as11.PossibleState.Add(this.ps21.Iid); this.as12 = new ActualFiniteState(Guid.NewGuid(), 1); this.as12.PossibleState.Add(this.ps11.Iid); this.as12.PossibleState.Add(this.ps22.Iid); this.asl1.ActualState.Add(this.as11.Iid); this.asl1.ActualState.Add(this.as12.Iid); this.asl2.PossibleFiniteStateList.Add(new OrderedItem { K = 1, V = this.psl2.Iid.ToString() }); this.as21 = new ActualFiniteState(Guid.NewGuid(), 1); this.as21.PossibleState.Add(this.ps21.Iid); this.as22 = new ActualFiniteState(Guid.NewGuid(), 1); this.as22.PossibleState.Add(this.ps22.Iid); this.asl2.ActualState.Add(this.as21.Iid); this.asl2.ActualState.Add(this.as22.Iid); this.possibleFiniteStateListslService.Setup( x => x.GetShallow(this.transaction, this.partition, It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)) .Returns(new List <Thing> { this.psl1, this.psl2 }); this.actualFiniteStateListService.Setup( x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.asl1, this.asl2 }); this.actualFiniteStateService.Setup( x => x.GetShallow(this.transaction, this.partition, It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)) .Returns(new List <Thing> { this.as11, this.as12 }); this.iterationService.Setup(x => x.GetActiveIteration(this.transaction, this.partition, this.securityContext.Object)) .Returns(this.iteration); this.parameter1 = new Parameter(Guid.NewGuid(), 1); this.parameter1.StateDependence = this.asl1.Iid; this.parameter2 = new Parameter(Guid.NewGuid(), 1); this.parameter2.StateDependence = this.asl1.Iid; this.parameter2.IsOptionDependent = true; this.parameterOverride1 = new ParameterOverride(Guid.NewGuid(), 1); this.parameterOverride1.Parameter = this.parameter1.Iid; this.parameterOverride2 = new ParameterOverride(Guid.NewGuid(), 1); this.parameterOverride2.Parameter = this.parameter2.Iid; this.parameterSubscription1 = new ParameterSubscription(Guid.NewGuid(), 1); this.parameterSubscription2 = new ParameterSubscription(Guid.NewGuid(), 1); this.parameter1.ParameterSubscription.Add(this.parameterSubscription1.Iid); this.parameterOverride2.ParameterSubscription.Add(this.parameterSubscription2.Iid); this.pvs11 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs12 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs21 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs22 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.povs11 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs12 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs21 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs22 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.psvs11 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.pvs11.Iid }; this.psvs12 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.pvs12.Iid }; this.psvs21 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.povs21.Iid }; this.psvs22 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.povs22.Iid }; this.parameter1.ValueSet.Add(this.pvs11.Iid); this.parameter1.ValueSet.Add(this.pvs12.Iid); this.parameter2.ValueSet.Add(this.pvs21.Iid); this.parameter2.ValueSet.Add(this.pvs22.Iid); this.parameterOverride1.ValueSet.Add(this.povs11.Iid); this.parameterOverride1.ValueSet.Add(this.povs12.Iid); this.parameterOverride2.ValueSet.Add(this.povs21.Iid); this.parameterOverride2.ValueSet.Add(this.povs22.Iid); this.parameterSubscription1.ValueSet.Add(this.psvs11.Iid); this.parameterSubscription1.ValueSet.Add(this.psvs12.Iid); this.parameterSubscription2.ValueSet.Add(this.psvs21.Iid); this.parameterSubscription2.ValueSet.Add(this.psvs22.Iid); this.parameterService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameter1, this.parameter2 }); this.parameterOverrideService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameterOverride1, this.parameterOverride2 }); this.parameterSubscriptionService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameterSubscription1, this.parameterSubscription2 }); this.parameterValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameter1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.pvs11, this.pvs12 }); this.parameterValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameter2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.pvs21, this.pvs22 }); this.parameterOverrideValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterOverride1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.povs11, this.povs12 }); this.parameterOverrideValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterOverride2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.povs21, this.povs22 }); this.parameterSubscriptionValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterSubscription1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.psvs11, this.psvs12 }); this.parameterSubscriptionValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterSubscription2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.psvs21, this.psvs22 }); this.defaultValueArrayFactory.Setup(x => x.CreateDefaultValueArray(It.IsAny <Guid>())).Returns(new ValueArray <string>(new[] { "-" })); this.finiteStateLogicService.ActualFiniteStateListService = this.actualFiniteStateListService.Object; this.finiteStateLogicService.ActualFiniteStateService = this.actualFiniteStateService.Object; this.finiteStateLogicService.IterationService = this.iterationService.Object; this.finiteStateLogicService.PossibleFiniteStateListService = this.possibleFiniteStateListslService.Object; this.finiteStateLogicService.StateDependentParameterUpdateService = this.parameterUpdateService; this.sideEffect.FiniteStateLogicService = this.finiteStateLogicService; this.parameterUpdateService.DefaultValueSetFactory = this.defaultValueArrayFactory.Object; this.parameterValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterValueSet>(), It.IsAny <Parameter>())).Returns(true); this.parameterOverrideValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterOverrideValueSet>(), It.IsAny <ParameterOverride>())).Returns(true); this.parameterSubscriptionValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterSubscriptionValueSet>(), It.IsAny <ParameterSubscription>())).Returns(true); }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.thingDialognavigationService = new Mock <IThingDialogNavigationService>(); this.thingCreator = new Mock <IThingCreator>(); this.obfuscationService = new Mock <IObfuscationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()) .Returns(this.thingCreator.Object); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.modelsetup.RequiredRdl.Add(this.mrdl); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.sitedir.Model.Add(this.modelsetup); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.option1 = new Option(Guid.NewGuid(), this.cache, this.uri); this.option2 = new Option(Guid.NewGuid(), this.cache, this.uri); this.stateList = new ActualFiniteStateList(Guid.NewGuid(), this.cache, this.uri); this.state1 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.state2 = new PossibleFiniteState(Guid.NewGuid(), this.cache, this.uri); this.posStateList = new PossibleFiniteStateList(Guid.NewGuid(), this.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.cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state1 }, Kind = ActualFiniteStateKind.MANDATORY }); this.stateList.ActualState.Add(new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri) { PossibleState = new List <PossibleFiniteState> { this.state2 }, Kind = ActualFiniteStateKind.FORBIDDEN }); this.activeDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.someotherDomain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.session = new Mock <ISession>(); this.qqParamType = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) { Name = "PTName", ShortName = "PTShortName" }; // Array parameter type with components this.apType = new ArrayParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.apType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); // compound parameter type with components this.cptType = new CompoundParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "APTName", ShortName = "APTShortName" }; this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.cptType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.cache, this.uri) { Iid = Guid.NewGuid(), ParameterType = this.qqParamType }); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.activeDomain }; 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 }; var person = new Person(Guid.NewGuid(), null, null) { GivenName = "test", Surname = "test" }; var participant = new Participant(Guid.NewGuid(), null, null) { Person = person, SelectedDomain = this.activeDomain }; this.session.Setup(x => x.ActivePerson).Returns(person); this.modelsetup.Participant.Add(participant); this.model.Iteration.Add(this.iteration); this.iteration.Element.Add(this.elementDefinition); this.iteration.Option.Add(this.option1); this.iteration.Option.Add(this.option2); this.elementDefinitionForUsage1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementDefinitionForUsage2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { Owner = this.someotherDomain }; this.elementUsage1.ElementDefinition = this.elementDefinitionForUsage1; this.elementUsage2.ElementDefinition = this.elementDefinitionForUsage2; this.parameterGroup1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup3 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup1ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup2ForUsage2 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameterGroup3ForUsage1 = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter3 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter4 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameterForStates = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain, StateDependence = this.stateList }; this.parameter5ForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.someotherDomain }; this.parameter6ForOverride = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.qqParamType, Owner = this.activeDomain }; this.parameter6Override = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = this.parameter6ForOverride, Owner = this.activeDomain }; this.parameterArray = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.apType, Owner = this.someotherDomain }; this.parameterCompound = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterCompoundForSubscription = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.cptType, Owner = this.someotherDomain }; this.parameterSubscriptionCompound = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Owner = this.activeDomain }; this.parameterCompoundForSubscription.ParameterSubscription.Add(this.parameterSubscriptionCompound); this.parameterForOptions = new Parameter(Guid.NewGuid(), this.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.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup1ForUsage1); this.elementDefinitionForUsage2.ParameterGroup.Add(this.parameterGroup2ForUsage2); this.elementDefinitionForUsage1.ParameterGroup.Add(this.parameterGroup3ForUsage1); 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; this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }