/// <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.measurementUnitsBrowserViewModel = new MeasurementUnitsBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.measurementScalesBrowserViewModel = new MeasurementScalesBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.rulesBrowserViewModel = new RulesBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.categoryBrowserViewModel = new CategoryBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService); this.parameterTypesBrowserViewModel = new ParameterTypesBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService, this.FavoritesService); this.Session = session; } if (sessionChange.Status == SessionStatus.Closed) { this.CloseAll(); this.Session = null; } }
public void VerifyThatRdlShortnameIsUpdated() { var vm = new RulesBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null); var sRdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); sRdl.Container = this.siteDir; var cat = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat1", ShortName = "1", Container = sRdl }; var cat2 = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat2", ShortName = "2", Container = sRdl }; CDPMessageBus.Current.SendObjectChangeEvent(cat, EventKind.Added); CDPMessageBus.Current.SendObjectChangeEvent(cat2, EventKind.Added); var rev = typeof(Thing).GetProperty("RevisionNumber"); rev.SetValue(sRdl, 3); sRdl.ShortName = "test"; CDPMessageBus.Current.SendObjectChangeEvent(sRdl, EventKind.Updated); Assert.IsTrue(vm.Rules.Count(x => x.ContainerRdl == "test") == 2); }
public void Setup() { this.session = new Mock <ISession>(); this.uri = new Uri("http://www.rheagroup.com"); this.assembler = new Assembler(this.uri); this.permissionService = new Mock <IPermissionService>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "site directory" }; this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri) { GivenName = "John", Surname = "Doe" }; var siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.siteDir.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.RulesViewModel = new RulesBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null); }
public void VerifyThatCategoriesFromExistingRdlsAreLoaded() { var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); var rule1 = new BinaryRelationshipRule(Guid.NewGuid(), null, null); var rule2 = new MultiRelationshipRule(Guid.NewGuid(), null, null); siterefenceDataLibrary.Rule.Add(rule1); siterefenceDataLibrary.Rule.Add(rule2); this.siteDir.SiteReferenceDataLibrary.Add(siterefenceDataLibrary); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null); var rule3 = new BinaryRelationshipRule(Guid.NewGuid(), null, null); var rule4 = new MultiRelationshipRule(Guid.NewGuid(), null, null); modelReferenceDataLibrary.Rule.Add(rule3); modelReferenceDataLibrary.Rule.Add(rule4); engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary); this.siteDir.Model.Add(engineeringModelSetup); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary) { modelReferenceDataLibrary }); var browser = new RulesBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null); Assert.AreEqual(4, browser.Rules.Count); }
/// <summary> /// Close all the panels and dispose of them /// </summary> private void CloseAll() { this.PanelNavigationService.CloseInAddIn(this.measurementUnitsBrowserViewModel); this.measurementUnitsBrowserViewModel = null; this.PanelNavigationService.CloseInAddIn(this.measurementScalesBrowserViewModel); this.measurementScalesBrowserViewModel = null; this.PanelNavigationService.CloseInAddIn(this.rulesBrowserViewModel); this.rulesBrowserViewModel = null; this.PanelNavigationService.CloseInAddIn(this.categoryBrowserViewModel); this.categoryBrowserViewModel = null; this.PanelNavigationService.CloseInAddIn(this.parameterTypesBrowserViewModel); this.parameterTypesBrowserViewModel = null; }