public void VerifyThatEventAreCaught() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); revision.SetValue(this.siteDir, 2); this.siteDir.Organization.Add(this.orga2); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(2, vm.Organizations.Count); var row = vm.Organizations.Single(x => x.Thing == this.orga2); Assert.AreEqual(1, row.ContainedRows.Count); revision.SetValue(this.siteDir, 20); this.person.Organization = null; CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(0, row.ContainedRows.Count); revision.SetValue(this.siteDir, 30); this.siteDir.Organization.Remove(this.orga2); CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated); Assert.AreEqual(1, vm.Organizations.Count); }
/// <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 VerifyStringProperties() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); Assert.That(vm.Caption, Is.Not.Null.Or.Empty); Assert.That(vm.ToolTip, Is.Not.Null.Or.Empty); }
public void VerifyThatAnOrganizationCantBeAddedMoreThanOnce() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); var organization = new Organization(Guid.NewGuid(), null, this.uri) { Name = "1", ShortName = "1" }; CDPMessageBus.Current.SendObjectChangeEvent(organization, EventKind.Added); CDPMessageBus.Current.SendObjectChangeEvent(organization, EventKind.Added); Assert.AreEqual(1, vm.Thing.Organization.Count); }
public void VerifyThatUpdateOnOrganizationAreCaught() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); this.orga1.Name = "rhea"; // workaround to modify a read-only field var type = this.orga1.GetType(); type.GetProperty("RevisionNumber").SetValue(this.orga1, 50); CDPMessageBus.Current.SendObjectChangeEvent(this.orga1, EventKind.Updated); var org = vm.Organizations.Single(); Assert.AreEqual("rhea", org.Name); }
public void VerifyThatReactiveCommandCanExecuteProperly() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); Assert.IsTrue(vm.CreateCommand.CanExecute(null)); Assert.IsFalse(vm.InspectCommand.CanExecute(null)); Assert.IsFalse(vm.UpdateCommand.CanExecute(null)); var organization = new Organization(Guid.NewGuid(), null, this.uri) { Name = "1", ShortName = "1" }; CDPMessageBus.Current.SendObjectChangeEvent(organization, EventKind.Added); vm.SelectedThing = vm.Organizations.Single(); vm.ComputePermission(); Assert.IsTrue(vm.InspectCommand.CanExecute(null)); Assert.IsTrue(vm.UpdateCommand.CanExecute(null)); }
/// <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; }
public void VerifyThatReactiveCommandsOpenDialogsOnExecute() { var vm = new OrganizationBrowserViewModel(this.session.Object, this.siteDir, this.dialogNavigation.Object, this.navigation.Object, null, null); vm.CreateCommand.Execute(null); this.dialogNavigation.Verify(x => x.Navigate(It.IsAny <Organization>(), It.IsAny <ThingTransaction>(), this.session.Object, true, ThingDialogKind.Create, this.dialogNavigation.Object, It.IsAny <Thing>(), null)); var organization = new Organization(Guid.NewGuid(), null, this.uri) { Name = "1", ShortName = "1" }; CDPMessageBus.Current.SendObjectChangeEvent(organization, EventKind.Added); vm.InspectCommand.Execute(null); Assert.Throws <MockException>(() => this.dialogNavigation.Verify(x => x.Navigate(organization, It.IsAny <ThingTransaction>(), this.session.Object, true, ThingDialogKind.Inspect, this.dialogNavigation.Object, It.IsAny <Thing>(), null))); vm.SelectedThing = vm.Organizations.Single(); vm.InspectCommand.Execute(null); this.dialogNavigation.Verify(x => x.Navigate(It.IsAny <Organization>(), It.IsAny <ThingTransaction>(), this.session.Object, true, ThingDialogKind.Inspect, this.dialogNavigation.Object, It.IsAny <Thing>(), null)); vm.UpdateCommand.Execute(null); }