public void VerifyThatRdlShortnameIsUpdated() { var vm = new CategoryBrowserViewModel(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 Category(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat1", ShortName = "1", Container = sRdl }; var cat2 = new Category(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.Categories.All(x => x.ContainerRdl == "test")); }
public void VerifyThatCategoriesFromExistingRdlsAreLoaded() { var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); var cat1 = new Category(Guid.NewGuid(), null, null); var cat2 = new Category(Guid.NewGuid(), null, null); siterefenceDataLibrary.DefinedCategory.Add(cat1); siterefenceDataLibrary.DefinedCategory.Add(cat2); this.siteDir.SiteReferenceDataLibrary.Add(siterefenceDataLibrary); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null); var cat3 = new Category(Guid.NewGuid(), null, null); var cat4 = new Category(Guid.NewGuid(), null, null); modelReferenceDataLibrary.DefinedCategory.Add(cat3); modelReferenceDataLibrary.DefinedCategory.Add(cat4); 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 CategoryBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null); Assert.AreEqual(4, browser.Categories.Count); }
public void VerifyThatUpdatedCategoryEventAreCaught() { var vm = new CategoryBrowserViewModel(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 Category(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat1", ShortName = "1", Container = sRdl }; var cat2 = new Category(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); cat.SuperCategory.Add(cat2); // workaround to modify a read-only field var type = cat.GetType(); type.GetProperty("RevisionNumber").SetValue(cat, 50); CDPMessageBus.Current.SendObjectChangeEvent(cat, EventKind.Updated); var row1 = vm.Categories.First(); Assert.AreEqual(cat.Name, row1.Name); Assert.AreEqual(cat.ShortName, row1.ShortName); Assert.AreEqual((cat.Container as ReferenceDataLibrary).Name, row1.ContainerRdl); Assert.IsTrue(row1.SuperCategories.Contains(cat2.ShortName)); }
/// <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 VerifyProperties() { var vm = new CategoryBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null); Assert.IsTrue(vm.Caption.Contains(this.siteDir.Name)); Assert.That(vm.ToolTip, Is.Not.Null.Or.Not.Empty); Assert.IsNotNull(vm.Session); }
/// <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; }
public void VerifyThatCategoryEventAreCaught() { var vm = new CategoryBrowserViewModel(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 Category(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat1", ShortName = "1", Container = sRdl }; CDPMessageBus.Current.SendObjectChangeEvent(cat, EventKind.Added); Assert.AreEqual(1, vm.Categories.Count); CDPMessageBus.Current.SendObjectChangeEvent(cat, EventKind.Removed); Assert.AreEqual(0, vm.Categories.Count); }