public void VerifyThatNewRolesAreAdded() { var viewmodel = new RoleBrowserViewModel(this.session.Object, this.siteDir, null, this.navigation.Object, null, null); var newPersonRole = new PersonRole(Guid.NewGuid(), null, this.uri); var newParticipantRole = new ParticipantRole(Guid.NewGuid(), null, this.uri); this.siteDir.PersonRole.Add(newPersonRole); this.siteDir.ParticipantRole.Add(newParticipantRole); var rev = typeof(Thing).GetProperty("RevisionNumber"); rev.SetValue(this.siteDir, 3); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); var personRoleRow = viewmodel.Roles.First(); var participantRoleRow = viewmodel.Roles.Last(); Assert.AreEqual(2, personRoleRow.ContainedRows.Count); Assert.AreEqual(2, participantRoleRow.ContainedRows.Count); this.siteDir.PersonRole.Clear(); this.siteDir.ParticipantRole.Clear(); rev.SetValue(this.siteDir, 5); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(0, personRoleRow.ContainedRows.Count); Assert.AreEqual(0, participantRoleRow.ContainedRows.Count); viewmodel.Dispose(); }
/// <summary> /// The event-handler that is invoked by the subscription that listens for updates /// on the <see cref="Session"/> that is being represented by the view-model /// </summary> /// <param name="sessionChange"> /// The payload of the event that is being handled /// </param> private void SessionChangeEventHandler(SessionEvent sessionChange) { if (this.FluentRibbonManager == null) { return; } if (!this.FluentRibbonManager.IsActive) { return; } if (sessionChange.Status == SessionStatus.Open) { var session = sessionChange.Session; var siteDirectory = session.RetrieveSiteDirectory(); this.domainOfExpertiseBrowserViewModel = new DomainOfExpertiseBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.modelBrowserViewModel = new ModelBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.naturalLanguageBrowserViewModel = new NaturalLanguageBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.organizationBrowserViewModel = new OrganizationBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.personBrowserViewModel = new PersonBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.roleBrowserViewModel = new RoleBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.siteRdlBrowserViewModel = new SiteRdlBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.Session = session; } if (sessionChange.Status == SessionStatus.Closed) { this.CloseAll(); this.Session = null; } }
public void VerifyThatSelectedSessionAreDisplayedInPropertyGrid() { var viewmodel = new RoleBrowserViewModel(this.session.Object, this.siteDir, null, this.navigation.Object, null, null); viewmodel.SelectedThing = viewmodel.Roles.First(); this.navigation.Verify(x => x.Open(It.IsAny <Thing>(), this.session.Object)); }
public void VerifyThatSelectedSessionAreDisplayedInPropertyGrid() { var viewmodel = new RoleBrowserViewModel(this.session.Object, this.siteDir, null, this.navigation.Object, null, null); var selectedThingChangedRaised = false; CDPMessageBus.Current.Listen <SelectedThingChangedEvent>().Subscribe(_ => selectedThingChangedRaised = true); viewmodel.SelectedThing = viewmodel.Roles.First(); Assert.IsTrue(selectedThingChangedRaised); }
public void VerifyThatPropertiesAreSet() { var viewmodel = new RoleBrowserViewModel(this.session.Object, this.siteDir, null, this.navigation.Object, null, null); Assert.That(viewmodel.Caption, Is.Not.Null.Or.Empty); Assert.That(viewmodel.ToolTip, Is.Not.Null.Or.Empty); Assert.IsTrue(viewmodel.CreateParticipantRoleCommand.CanExecute(null)); Assert.IsTrue(viewmodel.CreatePersonRoleCommand.CanExecute(null)); var personRoleRow = viewmodel.Roles.First(); var participantRoleRow = viewmodel.Roles.Last(); Assert.IsNotEmpty(personRoleRow.ContainedRows); Assert.IsNotEmpty(participantRoleRow.ContainedRows); }
/// <summary> /// Close all the panels and dispose of them /// </summary> private void CloseAll() { this.PanelNavigationService.Close(this.domainOfExpertiseBrowserViewModel, false); this.domainOfExpertiseBrowserViewModel = null; this.PanelNavigationService.Close(this.modelBrowserViewModel, false); this.modelBrowserViewModel = null; this.PanelNavigationService.Close(this.naturalLanguageBrowserViewModel, false); this.naturalLanguageBrowserViewModel = null; this.PanelNavigationService.Close(this.organizationBrowserViewModel, false); this.organizationBrowserViewModel = null; this.PanelNavigationService.Close(this.personBrowserViewModel, false); this.personBrowserViewModel = null; this.PanelNavigationService.Close(this.roleBrowserViewModel, false); this.roleBrowserViewModel = null; this.PanelNavigationService.Close(this.siteRdlBrowserViewModel, false); this.siteRdlBrowserViewModel = null; }