/// <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 VerifyThatExecuteCreateWorks() { var vm = new PersonBrowserViewModel(this.session.Object, this.siteDir, this.navigation.Object, this.panelnavigation.Object, null, null); vm.CreateCommand.Execute(null); this.navigation.Verify(x => x.Navigate(It.IsAny <Person>(), It.IsAny <IThingTransaction>(), this.session.Object, true, ThingDialogKind.Create, this.navigation.Object, It.IsAny <Thing>(), null)); }
public void VerifyPanelProperties() { var browser = new PersonBrowserViewModel(this.session.Object, this.siteDir, this.navigation.Object, this.panelnavigation.Object, null, null); Assert.AreEqual("Persons, site directory", browser.Caption); Assert.AreEqual("site directory\nhttp://www.rheagroup.com/\n ", browser.ToolTip); Assert.AreEqual(1, browser.PersonRowViewModels.Count); Assert.AreEqual(this.session.Object, browser.Session); }
public void VerifyThatEditCommandWorks() { var vm = new PersonBrowserViewModel(this.session.Object, this.siteDir, this.navigation.Object, this.panelnavigation.Object, null, null); vm.SelectedThing = vm.PersonRowViewModels.First(); vm.UpdateCommand.Execute(null); this.navigation.Verify(x => x.Navigate(It.IsAny <Person>(), It.IsAny <IThingTransaction>(), this.session.Object, true, ThingDialogKind.Update, this.navigation.Object, It.IsAny <Thing>(), null)); }
public void VerifyThatEventAreCaught() { var vm = new PersonBrowserViewModel(this.session.Object, this.siteDir, this.navigation.Object, this.panelnavigation.Object, null, null); var pers = new Person(Guid.NewGuid(), this.cache, this.uri) { ShortName = "new" }; this.siteDir.Person.Add(pers); this.revision.SetValue(this.siteDir, 2); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(2, vm.PersonRowViewModels.Count); this.revision.SetValue(this.siteDir, 3); this.siteDir.Person.Remove(pers); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(1, vm.PersonRowViewModels.Count); }
/// <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; }