public void VerifyThatCreateIterationCommandWorks() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); var viewmodel = new ModelBrowserViewModel(this.session.Object, this.session.Object.RetrieveSiteDirectory(), this.thingDialogNavigationService.Object, this.navigationService.Object, null, null); var model = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); model.StudyPhase = StudyPhaseKind.DESIGN_SESSION_PHASE; var participant = new Participant(Guid.NewGuid(), null, this.uri); participant.Person = new Person(Guid.NewGuid(), null, this.uri) { GivenName = "blabla", Surname = "blabla" }; model.Participant.Add(participant); model.IterationSetup.Add(new IterationSetup()); var domain = new DomainOfExpertise(); model.ActiveDomain.Add(domain); this.siteDirectory.Model.Add(model); revPropertyInfo.SetValue(this.siteDirectory, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDirectory, EventKind.Updated); var modelRow = viewmodel.ModelSetup.Single(); var iterationFolderRow = modelRow.ContainedRows.OfType <FolderRowViewModel>().Single(x => x.Name == "Iterations"); viewmodel.SelectedThing = iterationFolderRow; viewmodel.ComputePermission(); Assert.IsTrue(viewmodel.CanCreateParticipant); Assert.IsTrue(viewmodel.CanCreateIterationSetup); Assert.IsTrue(viewmodel.CanCreateEngineeringModelSetup); viewmodel.PopulateContextMenu(); Assert.AreEqual(2, viewmodel.ContextMenu.Count); viewmodel.CreateIterationSetupCommand.Execute(null); this.thingDialogNavigationService.Verify(x => x.Navigate(It.IsAny <IterationSetup>(), It.IsAny <IThingTransaction>(), this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object, It.IsAny <EngineeringModelSetup>(), null)); }
public void VerifyThatForSingleParticipantDeleteMenuIsNotShown() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); var viewmodel = new ModelBrowserViewModel(this.session.Object, this.session.Object.RetrieveSiteDirectory(), null, this.navigationService.Object, null, null); var model = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); model.StudyPhase = StudyPhaseKind.DESIGN_SESSION_PHASE; var participant = new Participant(Guid.NewGuid(), null, this.uri); participant.Person = new Person(Guid.NewGuid(), null, this.uri) { GivenName = "blabla", Surname = "blabla" }; model.Participant.Add(participant); model.IterationSetup.Add(new IterationSetup()); var domain = new DomainOfExpertise(); model.ActiveDomain.Add(domain); this.siteDirectory.Model.Add(model); revPropertyInfo.SetValue(this.siteDirectory, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDirectory, EventKind.Updated); viewmodel.ComputePermission(); Assert.IsFalse(viewmodel.CanCreateParticipant); Assert.IsFalse(viewmodel.CanCreateIterationSetup); var modelRow = viewmodel.ModelSetup.Single(); viewmodel.SelectedThing = modelRow; viewmodel.ComputePermission(); Assert.IsTrue(viewmodel.CanCreateParticipant); Assert.IsTrue(viewmodel.CanCreateIterationSetup); Assert.IsTrue(viewmodel.CanCreateEngineeringModelSetup); viewmodel.PopulateContextMenu(); Assert.AreEqual(7, viewmodel.ContextMenu.Count); var participantFolderRow = modelRow.ContainedRows.OfType <FolderRowViewModel>().Single(x => x.Name == "Participants"); var iterationFolderRow = modelRow.ContainedRows.OfType <FolderRowViewModel>().Single(x => x.Name == "Iterations"); viewmodel.SelectedThing = participantFolderRow; viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(2, viewmodel.ContextMenu.Count); viewmodel.SelectedThing = iterationFolderRow; viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(2, viewmodel.ContextMenu.Count); var participantRow = participantFolderRow.ContainedRows.OfType <ModelParticipantRowViewModel>().Single(x => x.Name == "blabla blabla"); viewmodel.SelectedThing = participantRow; viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(3, viewmodel.ContextMenu.Count); foreach (var conMenu in viewmodel.ContextMenu) { Assert.AreNotEqual("Delete this Participant", conMenu.Header); } var iterationRow = iterationFolderRow.ContainedRows.Single(); viewmodel.SelectedThing = iterationRow; viewmodel.ComputePermission(); viewmodel.PopulateContextMenu(); Assert.AreEqual(4, viewmodel.ContextMenu.Count); }