public void VerifyThatSetTopElementWorks() { var def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(def2); this.iteration.TopElement = this.elementDef; var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var defRow = (ElementDefinitionRowViewModel)vm.ElementDefinitionRowViewModels.Single(x => x.Thing.Iid == this.elementDef.Iid); var def2Row = (ElementDefinitionRowViewModel)vm.ElementDefinitionRowViewModels.Single(x => x.Thing.Iid == def2.Iid); Assert.IsTrue(defRow.IsTopElement); Assert.IsFalse(def2Row.IsTopElement); this.iteration.TopElement = def2; this.rev.SetValue(this.iteration, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.IsFalse(defRow.IsTopElement); Assert.IsTrue(def2Row.IsTopElement); this.iteration.Element.Remove(def2); this.rev.SetValue(this.iteration, 51); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.IsTrue(def2Row.IsTopElement); }
public void VerifyThatIfEngineeringModelSetupIsChangedBrowserIsUpdated() { var domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "System", ShortName = "SYS" }; this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(domain, null) } }); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("ModelSetup", vm.CurrentModel); var type = this.engineeringModelSetup.GetType(); var revisionNumber = type.GetProperty("RevisionNumber"); this.engineeringModelSetup.Name = "testing"; revisionNumber.SetValue(this.engineeringModelSetup, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.engineeringModelSetup, EventKind.Updated); Assert.AreEqual("testing", vm.CurrentModel); }
public void VerifyThatDragCategorySetsCopyEffectAndCanBeDropped() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); elementDefinition.Owner = domainOfExpertise; var category = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "PROD", Name = "Products" }; category.PermissibleClass.Add(ClassKind.ElementDefinition); this.modelReferenceDataLibrary.DefinedCategory.Add(category); this.iteration.Element.Add(elementDefinition); var browser = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, null, this.dialogNavigationService.Object, null, null, null); var row = new ElementDefinitionRowViewModel(elementDefinition, domainOfExpertise, this.session.Object, browser, this.obfuscationService.Object); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(category); dropInfo.SetupProperty(x => x.Effects); row.DragOver(dropInfo.Object); Assert.That(dropInfo.Object.Effects, Is.EqualTo(DragDropEffects.Copy)); row.Drop(dropInfo.Object); Assert.IsFalse(row.HasError); }
public void VerifyThatElementDefArePopulated() { this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.AreEqual(1, vm.ElementDefinitionRowViewModels.Count); Assert.IsNotNull(vm.Caption); Assert.IsNotNull(vm.ToolTip); Assert.IsNotNull(vm.DataSource); Assert.IsNotNull(vm.CurrentModel); Assert.IsNotNull(vm.DomainOfExpertise); Assert.AreEqual(0, vm.CurrentIteration); var row = (ElementDefinitionRowViewModel)vm.ElementDefinitionRowViewModels.First(); Assert.That(row.Name, Is.Not.Null.Or.Empty); Assert.IsNotNull(row.Owner); this.elementDef.Name = "updated"; this.elementDef.Owner = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "test" }; // workaround to modify a read-only field this.rev.SetValue(this.elementDef, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.elementDef, EventKind.Updated); Assert.AreEqual(this.elementDef.Name, row.Name); Assert.AreSame(this.elementDef.Owner, row.Owner); }
/// <summary> /// Show or close the <see cref="ElementDefinitionsBrowserViewModel"/> /// </summary> /// <param name="iterationId"> /// the unique id of the <see cref="Iteration"/> that is being represented by the <see cref="ElementDefinitionsBrowserViewModel"/> /// </param> private void ShowOrCloseElementDefinitionsBrowser(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.openElementDefinitionBrowsers.SingleOrDefault(x => x.Thing == iteration); if (browser != null) { this.PanelNavigationService.CloseInAddIn(browser); this.openElementDefinitionBrowsers.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 ElementDefinitionsBrowserViewModel(iteration, this.Session, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService, this.parameterSubscriptionBatchService, this.changeOwnershipBatchService); this.openElementDefinitionBrowsers.Add(browser); this.PanelNavigationService.OpenInAddIn(browser); }
public void Verify_that_ExecuteBatchDeleteSubscriptionCommand_works_as_expected() { this.messageBoxService.Setup(m => m.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>())).Returns(MessageBoxResult.OK); 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 parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.elementDef, ParameterType = this.pt, }; parameter.ParameterSubscription.Add(new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.domain }); this.elementDef.Parameter.Add(parameter); this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, this.dialogNavigationService.Object, null, this.parameterSubscriptionBatchService.Object, null); vm.PopulateContextMenu(); Assert.AreEqual(2, vm.ContextMenu.Count); vm.BatchDeleteSubscriptionCommand.Execute(null); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()), Times.Exactly(1)); this.parameterSubscriptionBatchService.Verify(x => x.Delete(this.session.Object, this.iteration, false, It.IsAny <IEnumerable <Category> >(), It.IsAny <IEnumerable <DomainOfExpertise> >(), It.IsAny <IEnumerable <ParameterType> >(), It.IsAny <Func <IEnumerable <Parameter>, bool> >()), Times.Exactly(1)); }
public async Task VerifyDropElementDefExceptionCaught() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.sitedir.Domain.Add(domainOfExpertise); this.engineeringModelSetup.ActiveDomain.Add(domainOfExpertise); var model2 = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); var modelsetup2 = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelIid = model2.Iid }; model2.EngineeringModelSetup = modelsetup2; modelsetup2.ActiveDomain.Add(domainOfExpertise); this.sitedir.Model.Add(modelsetup2); var model2Iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); var def = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = domainOfExpertise }; model2.Iteration.Add(model2Iteration); model2Iteration.Element.Add(def); this.assembler.Cache.TryAdd(new CacheKey(model2.Iid, null), new Lazy <Thing>(() => model2)); this.assembler.Cache.TryAdd(new CacheKey(model2Iteration.Iid, null), new Lazy <Thing>(() => model2Iteration)); this.assembler.Cache.TryAdd(new CacheKey(def.Iid, model2Iteration.Iid), new Lazy <Thing>(() => def)); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); this.session.Setup(x => x.OpenIterations) .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(domainOfExpertise, null) }, { model2Iteration, new Tuple <DomainOfExpertise, Participant>(domainOfExpertise, null) } }); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); dropinfo.Setup(x => x.Payload).Returns(def); dropinfo.SetupProperty(x => x.Effects); dropinfo.Object.Effects = DragDropEffects.All; dropinfo.Setup(x => x.KeyStates).Returns(DragDropKeyStates.LeftMouseButton); this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Throws(new Exception("test")); await vm.Drop(dropinfo.Object); Assert.AreEqual("test", vm.Feedback); }
public void VerifyThatCreateChangeRequestWorks() { this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, null, null, null, null, null); vm.SelectedThing = vm.ElementDefinitionRowViewModels.First(); vm.CreateChangeRequestCommand.Execute(null); this.thingDialogNavigationService.Verify(x => x.Navigate(It.Is <ChangeRequest>(cr => cr.Author == this.participant && cr.RelatedThing.Count == 1), It.IsAny <IThingTransaction>(), this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, It.IsAny <EngineeringModel>(), null)); }
public void VerifyThatNoneIsReturnedUponNullDomain() { this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(null, null) } }); this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); }
public void VerifyCreateParameterOverride() { var browser = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, this.panelNavigationService.Object, null, null, null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.elementDef.Owner, ElementDefinition = this.elementDef, Container = this.elementDef }; var usageRow = new ElementUsageRowViewModel(elementUsage, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var qk = new SimpleQuantityKind(); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.elementDef, ParameterType = qk, Owner = this.elementDef.Owner }; var parameterRow = new ParameterRowViewModel(parameter, this.session.Object, usageRow, false); Assert.IsFalse(browser.CreateOverrideCommand.CanExecute(null)); browser.SelectedThing = parameterRow; Assert.IsTrue(browser.CreateOverrideCommand.CanExecute(null)); browser.CreateOverrideCommand.Execute(parameter); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); browser.SelectedThing = null; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once); var paramtType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); paramtType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri), Scale = null }); parameter.ParameterType = paramtType; var elementDefRow = new ElementDefinitionRowViewModel(this.elementDef, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, elementDefRow, false); browser.SelectedThing = parameterValueBaseRow; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter, Owner = this.elementDef.Owner }; parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameterOverride, 0, this.session.Object, null, null, usageRow, false); browser.SelectedThing = parameterValueBaseRow; browser.CreateOverrideCommand.Execute(null); }
public void VerifyThatDragWorks() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, this.panelNavigationService.Object, null, null, null, null); var draginfo = new Mock <IDragInfo>(); var dragSource = new Mock <IDragSource>(); draginfo.Setup(x => x.Payload).Returns(dragSource.Object); vm.StartDrag(draginfo.Object); dragSource.Verify(x => x.StartDrag(draginfo.Object)); }
public void VerifyThatRefocusWorks() { var group = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.pt }; var def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); var usage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); var paramOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter2 }; parameter2.ParameterType = this.pt; var usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { ElementDefinition = def2 }; def2.Parameter.Add(parameter2); usage.ParameterOverride.Add(paramOverride); usage.ElementDefinition = def2; this.elementDef.Parameter.Add(parameter); this.elementDef.ParameterGroup.Add(group); this.elementDef.ContainedElement.Add(usage); this.elementDef.ContainedElement.Add(usage2); this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(def2); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); vm.PopulateContextMenu(); Assert.AreEqual(2, vm.ContextMenu.Count); var defRow = vm.ElementDefinitionRowViewModels.Last(); var usageRow = defRow.ContainedRows[2]; vm.SelectedThing = usageRow; vm.ChangeFocusCommand.Execute(null); var def2Row = vm.ElementDefinitionRowViewModels.Single(x => x.Thing == def2); Assert.IsTrue(vm.SelectedThing == def2Row); Assert.IsTrue(vm.FocusedRow == def2Row); }
public void VerifyThatDropsWorkIfNoDomain() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); var droptarget = new Mock <IDropTarget>(); dropinfo.Setup(x => x.TargetItem).Returns(droptarget.Object); vm.Drop(dropinfo.Object); droptarget.Verify(x => x.Drop(dropinfo.Object), Times.Once); }
public void VerifyThatSubscriptionCommandWorks() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session .Setup(x => x.OpenIterations) .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(new DomainOfExpertise(), null) } }); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.pt }; this.elementDef.Parameter.Add(parameter); this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.IsFalse(vm.CreateSubscriptionCommand.CanExecute(null)); var defRow = vm.ElementDefinitionRowViewModels.First(); vm.SelectedThing = defRow.ContainedRows.First(); vm.ComputePermission(); vm.PopulateContextMenu(); Assert.IsTrue(vm.CreateSubscriptionCommand.CanExecute(null)); vm.CreateSubscriptionCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); vm.SelectedThing = null; vm.CreateSubscriptionCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once); vm.SelectedThing = defRow; vm.CreateSubscriptionCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once); // Assert that is possible to subscribe to a ParameterOverride that is not owned by the current domain var parameterOverrideRow = defRow.ContainedRows.Last().ContainedRows.Last(); vm.SelectedThing = parameterOverrideRow; vm.ComputePermission(); Assert.IsTrue(vm.CanCreateSubscription); // Assert that is NOT possible to subscribe to a ParameterOverride that is owned by the current domain ((ParameterOverride)parameterOverrideRow.Thing).Owner = this.session.Object.OpenIterations.Values.Single().Item1; vm.ComputePermission(); Assert.IsFalse(vm.CanCreateSubscription); }
public void VerifyThatDragOverWorksWithoutDropTarget() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); dropinfo.Setup(x => x.Payload).Returns(this.elementDef); dropinfo.SetupProperty(x => x.Effects); dropinfo.Object.Effects = DragDropEffects.All; vm.DragOver(dropinfo.Object); Assert.AreNotEqual(DragDropEffects.All, dropinfo.Object.Effects); }
public void VerifyThatDropsWorkDomain() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); var droptarget = new Mock <IDropTarget>(); dropinfo.Setup(x => x.TargetItem).Returns(droptarget.Object); droptarget.Setup(x => x.Drop(It.IsAny <IDropInfo>())).Throws(new Exception("ex")); vm.Drop(dropinfo.Object); droptarget.Verify(x => x.Drop(dropinfo.Object)); Assert.AreEqual("ex", vm.Feedback); }
public void VerifyThatDragOverWorksWithDropTarget() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); var target = new Mock <IDropTarget>(); dropinfo.Setup(x => x.TargetItem).Returns(target.Object); dropinfo.SetupProperty(x => x.Effects); vm.DragOver(dropinfo.Object); target.Verify(x => x.DragOver(dropinfo.Object)); }
public void VerifyThatElementDefArePopulatedFromEvent() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); this.rev.SetValue(this.iteration, 50); this.iteration.Element.Add(this.elementDef); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.AreEqual(1, vm.ElementDefinitionRowViewModels.Count); this.rev.SetValue(this.iteration, 51); this.iteration.Element.Remove(this.elementDef); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.AreEqual(0, vm.ElementDefinitionRowViewModels.Count); }
public void VerifyThatParticipantWithoutDomainSelectedCannotDropOnElementDefBrowser() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri); var ratioScale = new RatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri); simpleQuantityKind.DefaultScale = ratioScale; var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); vm.DragOver(dropInfo.Object); Assert.AreEqual(dropInfo.Object.Effects, DragDropEffects.None); }
public void Verify_that_ExecuteBatchChangeOwnershipElementDefinition_works_as_expected() { var dialogResult = new CDP4EngineeringModel.ViewModels.Dialogs.ChangeOwnershipSelectionResult(true, this.domain, true); this.dialogNavigationService.Setup(x => x.NavigateModal(It.IsAny <IDialogViewModel>())).Returns(dialogResult); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, this.dialogNavigationService.Object, null, this.parameterSubscriptionBatchService.Object, this.changeOwnershipBatchService.Object); vm.SelectedThing = new ElementDefinitionRowViewModel(this.elementDef, this.domain, this.session.Object, null, this.obfuscationService.Object); vm.PopulateContextMenu(); vm.ChangeOwnershipCommand.Execute(null); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()), Times.Exactly(1)); this.changeOwnershipBatchService.Verify(x => x.Update(this.session.Object, It.IsAny <ElementDefinition>(), this.domain, true, It.IsAny <IEnumerable <ClassKind> >()), Times.Exactly(1)); }
public void Verify_that_ExecuteBatchCreateSubscriptionCommand_works_as_expected() { 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 ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, this.dialogNavigationService.Object, null, this.parameterSubscriptionBatchService.Object, null); vm.PopulateContextMenu(); Assert.AreEqual(2, vm.ContextMenu.Count); vm.BatchCreateSubscriptionCommand.Execute(null); this.dialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()), Times.Exactly(1)); this.parameterSubscriptionBatchService.Verify(x => x.Create(this.session.Object, this.iteration, false, It.IsAny <IEnumerable <Category> >(), It.IsAny <IEnumerable <DomainOfExpertise> >(), It.IsAny <IEnumerable <ParameterType> >()), Times.Exactly(1)); }
public void VerifyThatActiveDomainIsDisplayed() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "domain" }; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(domainOfExpertise); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.AreEqual("domain []", vm.DomainOfExpertise); domainOfExpertise = null; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(domainOfExpertise); vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); }
public void VerifThatIfDomainIsRenamedBrowserIsUpdated() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "System", ShortName = "SYS" }; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(domainOfExpertise); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.AreEqual("System [SYS]", vm.DomainOfExpertise); domainOfExpertise.Name = "Systems"; this.rev.SetValue(domainOfExpertise, 50); CDPMessageBus.Current.SendObjectChangeEvent(domainOfExpertise, EventKind.Updated); Assert.AreEqual("Systems [SYS]", vm.DomainOfExpertise); }
public void VerifyThatIfEngineeringModelSetupIsChangedBrowserIsUpdated() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "System", ShortName = "SYS" }; this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(domainOfExpertise); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); Assert.AreEqual("ModelSetup", vm.CurrentModel); this.engineeringModelSetup.Name = "testing"; this.rev.SetValue(this.engineeringModelSetup, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.engineeringModelSetup, EventKind.Updated); Assert.AreEqual("testing", vm.CurrentModel); }
public void VerifyThatDragOverWorksWithDropTarget() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); this.session.Setup(x => x.OpenIterations) .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(new DomainOfExpertise(), null) } }); var target = new Mock <IDropTarget>(); dropinfo.Setup(x => x.TargetItem).Returns(target.Object); dropinfo.SetupProperty(x => x.Effects); vm.DragOver(dropinfo.Object); target.Verify(x => x.DragOver(dropinfo.Object)); }
public void VerifyThatDragOverWorksWithoutDropTarget() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); var dropinfo = new Mock <IDropInfo>(); this.session.Setup(x => x.OpenIterations) .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(new DomainOfExpertise(), null) } }); dropinfo.Setup(x => x.Payload).Returns(this.elementDef); dropinfo.SetupProperty(x => x.Effects); dropinfo.Object.Effects = DragDropEffects.All; vm.DragOver(dropinfo.Object); Assert.AreNotEqual(DragDropEffects.All, dropinfo.Object.Effects); }
public void VerifyThatExecuteCreateParameterGroupWorks() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(new DomainOfExpertise(), null) } }); var group = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.elementDef.ParameterGroup.Add(group); this.iteration.Element.Add(this.elementDef); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null, null, null); var defRow = vm.ElementDefinitionRowViewModels.Single(); vm.SelectedThing = defRow.ContainedRows.Single(x => x.Thing is ParameterGroup); vm.CreateParameterGroup.Execute(null); this.thingDialogNavigationService.Verify(x => x.Navigate(It.Is <ParameterGroup>(gr => gr.ContainingGroup == group), It.IsAny <IThingTransaction>(), this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, It.IsAny <Thing>(), null)); }
public void VerifyThatActiveDomainIsDisplayed() { var domainOfExpertise = 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>(domainOfExpertise, this.participant) } }); var vm = new ElementDefinitionsBrowserViewModel(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, new Tuple <DomainOfExpertise, Participant>(null, null) } }); vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); Assert.AreEqual("None", vm.DomainOfExpertise); }
public void VerifyThatContextMenuIsPopulated() { var group = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = this.pt }; var def2 = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); var parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); var usage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri); var paramOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter2 }; parameter2.ParameterType = this.pt; var usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { ElementDefinition = def2 }; def2.Parameter.Add(parameter2); usage.ParameterOverride.Add(paramOverride); usage.ElementDefinition = def2; this.elementDef.Parameter.Add(parameter); this.elementDef.ParameterGroup.Add(group); this.elementDef.ContainedElement.Add(usage); this.elementDef.ContainedElement.Add(usage2); this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(def2); var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); vm.PopulateContextMenu(); Assert.AreEqual(2, vm.ContextMenu.Count); var defRow = vm.ElementDefinitionRowViewModels.Last(); vm.SelectedThing = defRow; vm.PopulateContextMenu(); Assert.AreEqual(18, vm.ContextMenu.Count); vm.SelectedThing = defRow.ContainedRows[0]; vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.SelectedThing = defRow.ContainedRows[1]; vm.PopulateContextMenu(); Assert.AreEqual(11, vm.ContextMenu.Count); var usageRow = defRow.ContainedRows[2]; var usage2Row = defRow.ContainedRows[3]; vm.SelectedThing = usageRow; vm.PopulateContextMenu(); Assert.AreEqual(8, vm.ContextMenu.Count); vm.SelectedThing = usageRow.ContainedRows.Single(); vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.SelectedThing = usage2Row.ContainedRows.Single(); vm.PopulateContextMenu(); Assert.AreEqual(12, vm.ContextMenu.Count); vm.Dispose(); }