public EplanEventListener()
        {
            onUserPreCloseProject
            .SetEvent("Eplan.EplApi.OnUserPreCloseProject");
            onUserPreCloseProject.EplanEvent +=
                new EventHandlerFunction(OnUserPreCloseProject);

            onPostOpenProject.SetEvent("Eplan.EplApi.OnPostOpenProject");
            onPostOpenProject.EplanEvent +=
                new EventHandlerFunction(OnPostOpenProject);

            onMainEnd.SetEvent("Eplan.EplApi.OnMainEnd");
            onMainEnd.EplanEvent +=
                new EventHandlerFunction(OnMainEnd);

            onMainStart.SetEvent("Eplan.EplApi.OnMainStart");
            onMainStart.EplanEvent +=
                new EventHandlerFunction(OnMainStart);

            onNotifyPageChanged.SetEvent("NotifyPageOpened");
            onNotifyPageChanged.EplanEvent +=
                new EventHandlerFunction(OnNotifyPageChanged);

            IEplanHelper         eplanHelper         = new EplanHelper();
            IModuleConfiguration moduleConfiguration =
                new ModuleConfiguration();
            IRunningProcess runningProcess =
                new RunningProcess(Process.GetCurrentProcess());

            idleTimeModule = new IdleTimeModule.IdleTimeModule(
                eplanHelper, moduleConfiguration, runningProcess);
        }
示例#2
0
        public void CloseApp_NullProjectNoMainWindow_NoInvokeEvent()
        {
            eplanHelperMock.Setup(x => x.GetCurrentProject())
            .Returns((IProject)null);
            idleTimeModule =
                new IdleTimeModule.IdleTimeModule(eplanHelperMock.Object,
                                                  moduleConfigurationMock.Object, runningProcessMock.Object);
            bool isInvokedEvent = false;

            idleTimeModule.BeforeClosingProject +=
                ((bool silentMode) => isInvokedEvent = true);
            runningProcessMock.Setup(x => x.CloseMainWindow()).Returns(false);

            idleTimeModule.CloseApplication();

            eplanHelperMock.Verify(x => x.GetCurrentProject(), Times.Once());
            runningProcessMock.Verify(x => x.CloseMainWindow(), Times.Once());
            runningProcessMock.Verify(x => x.Kill(), Times.Once());
            runningProcessMock.Verify(x => x.Close(), Times.Never());
            Assert.AreEqual(false, isInvokedEvent);
        }