Ejemplo n.º 1
0
        public async Task VerifyThatOnActionProductTreeWorks()
        {
            this.ribbonPart = new ProductTreeRibbonPart(this.order, this.panelNavigationService.Object, this.positiveDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var content = this.ribbonPart.GetContent("ShowProductTree_");

            await this.ribbonPart.OnAction($"ShowProductTree_{this.iteration.Iid}_{this.option1.Iid}", $"{this.iteration.Iid}_{this.option1.Iid}");

            this.panelNavigationService.Verify(x => x.OpenInAddIn(It.IsAny <IPanelViewModel>()));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
Ejemplo n.º 2
0
        public async Task VerifyThatOnActionShowShowPublicationsWorks()
        {
            this.ribbonPart = new EngineeringModelRibbonPart(this.order, this.panelNavigationService.Object, this.positiveDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            await this.ribbonPart.OnAction("CDP4_SelectModelToOpen");

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var content = this.ribbonPart.GetContent("ShowPublicationBrowser_");

            await this.ribbonPart.OnAction("ShowPublicationBrowser_" + this.iteration.Iid, this.iteration.Iid.ToString());

            this.panelNavigationService.Verify(x => x.Open(It.IsAny <IPanelViewModel>(), false));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
Ejemplo n.º 3
0
        public void VerifyThatWhenSessionIsClosedAfterModelWasOpenIterationsAreCleaned()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled(RibbonButtonId));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);
            CDPMessageBus.Current.SendObjectChangeEvent(this.CreateIteration(), EventKind.Added);

            Assert.IsTrue(this.ribbonPart.GetEnabled(RibbonButtonId));
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled(RibbonButtonId));
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
Ejemplo n.º 4
0
        public void VerifyThatOnActionIsExecuted()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            var iteration = this.CreateIteration();

            CDPMessageBus.Current.SendObjectChangeEvent(iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            this.ribbonPart.GetContent(RibbonButtonId);

            Assert.DoesNotThrowAsync(async() => await this.ribbonPart.OnAction($"Editor_{iteration.Iid}", iteration.Iid.ToString()));

            CDPMessageBus.Current.SendObjectChangeEvent(iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);
        }
Ejemplo n.º 5
0
        public void VerifyThatButtonsAreEnabledAsExpected()
        {
            this.ribbonPart = new RequirementRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null, this.officeApplicationWrapper.Object);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRequirements"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRequirements"));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowRequirements"));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRequirements"));

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRequirements"));
        }
Ejemplo n.º 6
0
        public async Task VerifyThatHideProductTreeWorks()
        {
            this.ribbonPart = new ProductTreeRibbonPart(this.order, this.panelNavigationService.Object, this.positiveDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var content = this.ribbonPart.GetContent("ShowProductTree_");

            await this.ribbonPart.OnAction($"ShowProductTree_{this.iteration.Iid}_{this.option1.Iid}", $"{this.iteration.Iid}_{this.option1.Iid}");

            this.panelNavigationService.Verify(x => x.OpenInAddIn(It.IsAny <IPanelViewModel>()));

            var allBrowsers = this.ribbonPart.GetAllOpenBrowsers();

            CDPMessageBus.Current.SendMessage(new HidePanelEvent(allBrowsers.SelectMany(x => x).First().Identifier));

            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <IPanelViewModel>()), Times.Once);

            CollectionAssert.IsEmpty(this.ribbonPart.GetAllOpenBrowsers().SelectMany(x => x));
        }
Ejemplo n.º 7
0
        public void VerifyThatOnActionProductTreeWorks()
        {
            this.ribbonPart = new RequirementRibbonPart(this.order, this.panelNavigationService.Object, this.positiveDialogNavigationService.Object, null, null, this.officeApplicationWrapper.Object);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var content = this.ribbonPart.GetContent("ShowRequirements");

            this.ribbonPart.OnAction(string.Format("ShowRequirement_{0}", this.iteration.Iid), string.Format("{0}", this.iteration.Iid));

            this.panelNavigationService.Verify(x => x.OpenInAddIn(It.IsAny <IPanelViewModel>()));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
Ejemplo n.º 8
0
        public void VerifyThatRegionManagerIsSet()
        {
            var ribbonManager = new FluentRibbonManager();

            var module = new SiteDirectoryModule(this.regionManager.Object, ribbonManager, this.panelNavigationService.Object, null, null, null);

            Assert.AreEqual(this.regionManager.Object, module.RegionManager);
        }
Ejemplo n.º 9
0
        public void VerifyThatButtonsAreEnabledAsExpected()
        {
            this.ribbonPart = new EngineeringModelRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToOpen"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToClose"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowElementDefinitionsBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOptionBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowFiniteStateBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPublicationBrowser_"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.IsTrue(this.ribbonPart.GetEnabled("CDP4_SelectModelToOpen"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToClose"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowElementDefinitionsBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOptionBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowFiniteStateBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPublicationBrowser_"));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Added);
            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            Assert.IsTrue(this.ribbonPart.GetEnabled("CDP4_SelectModelToOpen"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("CDP4_SelectModelToClose"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowElementDefinitionsBrowser_"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowOptionBrowser_"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowFiniteStateBrowser_"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowPublicationBrowser_"));

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Removed);
            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);

            Assert.IsTrue(this.ribbonPart.GetEnabled("CDP4_SelectModelToOpen"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToClose"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowElementDefinitionsBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOptionBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowFiniteStateBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPublicationBrowser_"));

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToOpen"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("CDP4_SelectModelToClose"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowElementDefinitionsBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOptionBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowFiniteStateBrowser_"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPublicationBrowser_"));
        }
Ejemplo n.º 10
0
        public void VerifyThatRegionManagerIsSet()
        {
            var ribbonManager = new FluentRibbonManager();

            var module = new BasicRdlModule(this.regionManager.Object, ribbonManager, this.panelNavigationService.Object, null, null, null);

            //module.Initialize();
            Assert.AreEqual(this.regionManager.Object, module.RegionManager);
        }
        public void SetUp()
        {
            this.SetupRecognizePackUir();

            this.uri           = new Uri("http://www.rheagroup.com");
            this.assembler     = new Assembler(this.uri);
            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), null, new Uri("http://test.com"));

            this.session = new Mock <ISession>();
            var LazySiteDirectory = new Lazy <Thing>(() => this.siteDirectory);

            this.assembler.Cache.GetOrAdd(new CacheKey(LazySiteDirectory.Value.Iid, null), LazySiteDirectory);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory);
            this.session.Setup(x => x.DataSourceUri).Returns("test");
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            var iterationDictionary = new Dictionary <CDP4Common.EngineeringModelData.Iteration, Tuple <DomainOfExpertise, Participant> >();

            this.session.Setup(x => x.OpenIterations).Returns(iterationDictionary);

            this.appSettingService = new Mock <IAppSettingsService <AddinAppSettings> >();
            this.appSettingService.Setup(x => x.AppSettings).Returns(new AddinAppSettings());

            this.panelNavigationService  = new Mock <IPanelNavigationService>();
            this.dialogNavigationService = new Mock <IDialogNavigationService>();
            this.serviceLocator          = new Mock <IServiceLocator>();

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            var dals          = new List <Lazy <IDal, IDalMetaData> >();
            var availableDals = new AvailableDals(dals);

            this.serviceLocator.Setup(x => x.GetInstance <AvailableDals>()).Returns(availableDals);

            this.assemblyLocationLoader = new Mock <IAssemblyInformationService>();

            var frameworkVersion = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Name;
            var testDirectory    = Path.Combine(Assembly.GetExecutingAssembly().Location, $"..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}");

#if DEBUG
            this.assemblyLocationLoader.Setup(x => x.GetLocation()).Returns(Path.GetFullPath(Path.Combine(testDirectory, $"CDP4IME{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}Debug{Path.DirectorySeparatorChar}{frameworkVersion}")));
#else
            this.assemblyLocationLoader.Setup(x => x.GetLocation()).Returns(Path.GetFullPath(Path.Combine(testDirectory, $"CDP4ServicesDal{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}Release{Path.DirectorySeparatorChar}{frameworkVersion}")));
#endif

            this.serviceLocator.Setup(s => s.GetInstance <IAssemblyInformationService>()).Returns(this.assemblyLocationLoader.Object);

            this.amountOfRibbonControls = 9;
            this.order = 1;

            this.ribbonPart = new AddinRibbonPart(this.order, this.panelNavigationService.Object, null, this.dialogNavigationService.Object, null, this.appSettingService.Object);

            var fluentRibbonManager = new FluentRibbonManager();
            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);
        }
Ejemplo n.º 12
0
        public void VerifyThatInjectedServicesAreSet()
        {
            var ribbonManager = new FluentRibbonManager();

            var module = new SystemsToolKitModule(ribbonManager, this.panelNavigationService.Object, this.thingDialogNavigationService.Object, this.dialogNavigationService.Object);

            Assert.AreEqual(ribbonManager, module.RibbonManager);
            Assert.AreEqual(this.panelNavigationService.Object, module.PanelNavigationService);
            Assert.AreEqual(this.thingDialogNavigationService.Object, module.ThingDialogNavigationService);
            Assert.AreEqual(this.dialogNavigationService.Object, module.DialogNavigationService);
        }
Ejemplo n.º 13
0
        public void VerifyThatOnActionIsNotExecutedWhenInterationIsNull()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.DoesNotThrowAsync(async() => await this.ribbonPart.OnAction($"Editor_", string.Empty));

            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
        public void VerifyThatIfFluentRibbonIsNotActiveTheSessionEventHasNoEffect()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = false;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(sessionEvent);
            Assert.IsNull(this.ribbonPart.Session);
        }
Ejemplo n.º 15
0
        public void SetUp()
        {
            this.panelNavigationService = new Mock <IPanelNavigationService>();
            this.fluentRibbonManager    = new FluentRibbonManager();

            this.existingribbonpartid = "test";
            this.ribbonXml            = string.Format("<test id=\"{0}\">this is a piece of test ribbon xml</test>", this.existingribbonpartid);

            this.nonexsitingribbonpartid = "a non exsting control";

            this.ribbonPart = new RibbonPartTest(1, this.panelNavigationService.Object, null, null, null);
            this.fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);
        }
Ejemplo n.º 16
0
        public void VerifyThatIfFluentRibbonIsNotActiveTheSessionEventHasNoEffect()
        {
            this.ribbonPart = new RequirementRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null, this.officeApplicationWrapper.Object);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = false;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var sessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(sessionEvent);
            Assert.IsNull(this.ribbonPart.Session);
        }
Ejemplo n.º 17
0
        public void VerifyThatOnActionIsNotExecutedWhenSessionIsNull()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var iteration = this.CreateIteration();

            CDPMessageBus.Current.SendObjectChangeEvent(iteration, EventKind.Added);

            Assert.DoesNotThrowAsync(async() => await this.ribbonPart.OnAction($"Editor_{iteration.Iid}", iteration.Iid.ToString()));

            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
Ejemplo n.º 18
0
        public void VerifyThatOnActionInvokesTheNavigationServiceOpenAndCloseMethod()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            // open viemodels
            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            this.ribbonPart.OnAction("ShowDomainsOfExpertise");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <DomainOfExpertiseBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowModels");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <ModelBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowLanguages");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <NaturalLanguageBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowOrganizations");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <OrganizationBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowRoles");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <RoleBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowPersons");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <PersonBrowserViewModel>(), false));

            this.ribbonPart.OnAction("ShowSiteRDLs");
            this.panelNavigationService.Verify(x => x.Open(It.IsAny <SiteRdlBrowserViewModel>(), false));

            // close viewmodels
            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            this.panelNavigationService.Verify(x => x.Close(It.IsAny <DomainOfExpertiseBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <ModelBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <NaturalLanguageBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <OrganizationBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <RoleBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <PersonBrowserViewModel>(), false));
            this.panelNavigationService.Verify(x => x.Close(It.IsAny <SiteRdlBrowserViewModel>(), false));
        }
Ejemplo n.º 19
0
        public async Task VerifyThatOnActionSelectModelToCloseOpenDialog()
        {
            this.ribbonPart = new EngineeringModelRibbonPart(this.order, this.panelNavigationService.Object, this.positiveDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            await this.ribbonPart.OnAction("CDP4_SelectModelToClose");

            this.positiveDialogNavigationService.Verify(x => x.NavigateModal(It.IsAny <IDialogViewModel>()));
        }
Ejemplo n.º 20
0
        public void VerifyThatOnActionIsNotExecutedWhenInvalidControlIsSpecified()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            var iteration = this.CreateIteration();

            Assert.DoesNotThrowAsync(async() => await this.ribbonPart.OnAction($"Editor", iteration.Iid.ToString()));

            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
        public void VerifyThatGetEnabledReturnsExpectedResult()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            this.ribbonPart.ExcelQuery = this.excelQuery.Object;

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));
        }
Ejemplo n.º 22
0
        public async Task VerifyThatOnActionSelectModelToOpenWithNegativeResultDoesNotOpenModel()
        {
            this.ribbonPart = new EngineeringModelRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.DoesNotThrow(() => this.ribbonPart.OnAction("CDP4_SelectModelToOpen"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            await this.ribbonPart.OnAction("CDP4_SelectModelToOpen");

            Assert.IsEmpty(this.ribbonPart.Iterations);
        }
        public async Task VerifyThatOnActionInvokesTheNavigationServiceOpenAndCloseMethod()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            // open viemodels
            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            await this.ribbonPart.OnAction("ShowMeasurementUnits");

            this.panelNavigationService.Verify(x => x.OpenExistingOrOpenInAddIn(It.IsAny <MeasurementUnitsBrowserViewModel>()));

            await this.ribbonPart.OnAction("ShowMeasurementScales");

            this.panelNavigationService.Verify(x => x.OpenExistingOrOpenInAddIn(It.IsAny <MeasurementScalesBrowserViewModel>()));

            await this.ribbonPart.OnAction("ShowParameterTypes");

            this.panelNavigationService.Verify(x => x.OpenExistingOrOpenInAddIn(It.IsAny <ParameterTypesBrowserViewModel>()));

            await this.ribbonPart.OnAction("ShowRules");

            this.panelNavigationService.Verify(x => x.OpenExistingOrOpenInAddIn(It.IsAny <RulesBrowserViewModel>()));

            await this.ribbonPart.OnAction("ShowCategories");

            this.panelNavigationService.Verify(x => x.OpenExistingOrOpenInAddIn(It.IsAny <CategoryBrowserViewModel>()));

            // close viewmodels
            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <MeasurementUnitsBrowserViewModel>()));
            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <MeasurementScalesBrowserViewModel>()));
            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <ParameterTypesBrowserViewModel>()));
            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <RulesBrowserViewModel>()));
            this.panelNavigationService.Verify(x => x.CloseInAddIn(It.IsAny <CategoryBrowserViewModel>()));
        }
        public void VerifyThatRibbonPartHandlesSessionOpenAndCloseEvent()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.AreEqual(this.session.Object, this.ribbonPart.Session);

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsNull(this.ribbonPart.Session);
        }
Ejemplo n.º 25
0
        public void VerifyThatGetEnabledReturnsExpectedResult()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowDomainsOfExpertise"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowModels"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowLanguages"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOrganizations"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPersons"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRoles"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowSiteRDLs"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowDomainsOfExpertise"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowModels"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowLanguages"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowOrganizations"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowPersons"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowRoles"));
            Assert.IsTrue(this.ribbonPart.GetEnabled("ShowSiteRDLs"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowDomainsOfExpertise"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowModels"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowLanguages"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowOrganizations"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowPersons"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowRoles"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("ShowSiteRDLs"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));
        }
Ejemplo n.º 26
0
        public void VerifyThatRibbonPartHandlesSessionOpenAndCloseEvent()
        {
            this.ribbonPart = new RequirementRibbonPart(this.order, this.panelNavigationService.Object, this.negativeDialogNavigationService.Object, null, null, this.officeApplicationWrapper.Object);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.AreEqual(this.session.Object, this.ribbonPart.Session);

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsNull(this.ribbonPart.Session);
        }
Ejemplo n.º 27
0
        public void VerifyThatGetEnabledReturnsExpectedResult()
        {
            var fluentRibbonManager = new FluentRibbonManager {
                IsActive = true
            };

            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled(RibbonButtonId));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled(RibbonButtonId));

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled(RibbonButtonId));
        }
        public void VerifyThatWhenSessionIsClosedAfterModelWasOpenIterationsAreCleaned()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            this.ribbonPart.ExcelQuery = this.excelQuery.Object;

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationNumber = 1
            };

            var iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            iteration.IterationSetup = iterationSetup;

            CDPMessageBus.Current.SendObjectChangeEvent(iteration, EventKind.Added);

            Assert.IsTrue(this.ribbonPart.GetEnabled("Rebuild"));

            Assert.AreEqual(1, this.ribbonPart.Iterations.Count);

            var closeSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Closed);

            CDPMessageBus.Current.SendMessage(closeSessionEvent);

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));

            Assert.AreEqual(0, this.ribbonPart.Iterations.Count);
        }
        public void VerifyThatButtonsAreEnabledWhenIterationIsLoaded()
        {
            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);

            Assert.IsFalse(this.ribbonPart.GetEnabled("Rebuild"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SynchronizeSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitAll"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitParameters"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("SubmitSubscriptions"));
            Assert.IsFalse(this.ribbonPart.GetEnabled("unknownRibbonControlId"));

            var openSessionEvent = new SessionEvent(this.session.Object, SessionStatus.Open);

            CDPMessageBus.Current.SendMessage(openSessionEvent);

            this.ribbonPart.ExcelQuery = this.excelQuery.Object;

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationNumber = 1
            };

            var iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            iteration.IterationSetup = iterationSetup;

            CDPMessageBus.Current.SendObjectChangeEvent(iteration, EventKind.Added);

            Assert.IsTrue(this.ribbonPart.GetEnabled("Rebuild"));

            // the other ribbon buttons depend on NetOffice and cannot be properly unit tested
        }
Ejemplo n.º 30
0
        public void SetUp()
        {
            this.SetupRecognizePackUir();

            this.uri       = new Uri("http://www.rheageoup.com");
            this.assembler = new Assembler(this.uri);

            this.session = new Mock <ISession>();
            var siteDirectory = new Lazy <Thing>(() => new SiteDirectory(Guid.NewGuid(), null, new Uri("http://test.com")));

            this.assembler.Cache.GetOrAdd(new CacheKey(siteDirectory.Value.Iid, null), siteDirectory);
            this.session.Setup(x => x.DataSourceUri).Returns("test");
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.panelNavigationService  = new Mock <IPanelNavigationService>();
            this.dialogNavigationService = new Mock <IDialogNavigationService>();
            this.serviceLocator          = new Mock <IServiceLocator>();

            this.amountOfRibbonControls = 4;
            this.order = 1;

            this.ribbonPart = new AddinRibbonPart(this.order, this.panelNavigationService.Object, null, null, null);

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IDialogNavigationService>())
            .Returns(this.dialogNavigationService.Object);

            var dals          = new List <Lazy <IDal, IDalMetaData> >();
            var availableDals = new AvailableDals(dals);

            this.serviceLocator.Setup(x => x.GetInstance <AvailableDals>()).Returns(availableDals);

            var fluentRibbonManager = new FluentRibbonManager();

            fluentRibbonManager.IsActive = true;
            fluentRibbonManager.RegisterRibbonPart(this.ribbonPart);
        }