/// <summary> /// Show or close the <see cref="FiniteStateBrowserViewModel"/> /// </summary> /// <param name="iterationId"> /// the unique id of the <see cref="Iteration"/> that is being represented by the <see cref="FiniteStateBrowserViewModel"/> /// </param> private void ShowOrCloseFiniteStateBrowser(string iterationId) { var uniqueId = Guid.Parse(iterationId); var iteration = this.Iterations.SingleOrDefault(x => x.Iid == uniqueId); if (iteration == null) { return; } // close the brower if it exists var browser = this.openFiniteStateBrowsers.SingleOrDefault(x => x.Thing == iteration); if (browser != null) { this.PanelNavigationService.CloseInAddIn(browser); this.openFiniteStateBrowsers.Remove(browser); return; } var model = (EngineeringModel)iteration.Container; if (model == null) { throw new InvalidOperationException("The Container of an Iteration is not a EngineeringModel."); } browser = new FiniteStateBrowserViewModel(iteration, this.Session, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService, this.parameterActualFiniteStateListApplicationBatchService); this.openFiniteStateBrowsers.Add(browser); this.PanelNavigationService.OpenInAddIn(browser); }
public void VerifyThatActiveDomainIsDisplayed() { var domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "domain" }; this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(domain, null) } }); var vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("domain []", vm.DomainOfExpertise); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, null } }); vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); }
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 VerifyThatDisposeWorks() { var viewmodel = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null, null); viewmodel.Dispose(); Assert.IsNull(viewmodel.Thing); }
public void VerifyThatPropertiesAreSet() { var viewmodel = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null, null); Assert.That(viewmodel.Caption, Is.Not.Null.Or.Empty); Assert.That(viewmodel.ToolTip, Is.Not.Null.Or.Empty); Assert.That(viewmodel.CurrentModel, Is.Not.Null.Or.Empty); Assert.That(viewmodel.DomainOfExpertise, Is.Not.Null.Or.Empty); Assert.IsNotNull(viewmodel.CurrentIteration); }
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 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 VerifyThatActiveDomainIsDisplayed() { var testDomain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "domain" }; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(testDomain); var vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null); Assert.AreEqual("domain []", vm.DomainOfExpertise); testDomain = null; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(testDomain); vm = new FiniteStateBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); }