Beispiel #1
0
        public TestResult DoTest()
        {
            NetOffice.Settings.MessageFilter.Enabled = true;
            MSProject.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                application = new MSProject.Application();

                application.ProjectTaskNewEvent += new MSProject.Application_ProjectTaskNewEventHandler(ApplicationProjectTaskNewEvent);
                application.ProjectBeforeCloseEvent += new MSProject.Application_ProjectBeforeCloseEventHandler(ApplicationProjectBeforeCloseEvent);
                application.ProjectBeforeTaskChangeEvent += new MSProject.Application_ProjectBeforeTaskChangeEventHandler(ApplicationProjectBeforeTaskChangeEvent);
                application.ProjectBeforeTaskDeleteEvent += new MSProject.Application_ProjectBeforeTaskDeleteEventHandler(ApplicationProjectBeforeTaskDeleteEvent);
               
                MSProject.Project newProject = application.Projects.Add();
                MSProject.Task task1 = newProject.Tasks.Add("Task 1");
                MSProject.Task task2 =  newProject.Tasks.Add("Task 2");
                
                task2.Delete();

                application.FileCloseAll(false);

                if (TaskDeleteEventCalled && TaskChangeEventCalled && BeforeCloseEventCalled && TaskChangeEventCalled)
                    return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
                else 
                {
                    string errorMessage = "";
                    if (!TaskDeleteEventCalled)
                        errorMessage += "ProjectBeforeTaskDeleteEvent failed ";
                    if (!TaskChangeEventCalled)
                        errorMessage += "ProjectBeforeTaskChangeEvent failed ";
                    if (!BeforeCloseEventCalled)
                        errorMessage += "ProjectBeforeCloseEvent failed ";
                    if (!TaskNewEventCalled)
                        errorMessage += "ProjectTaskNewEvent failed ";

                    return new TestResult(false, DateTime.Now.Subtract(startTime), errorMessage, null, "");
                }
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                NetOffice.Settings.MessageFilter.Enabled = false;

                if (null != application)
                {
                    application.Quit(false);
                    application.Dispose();
                }
            }
        }
Beispiel #2
0
        public TestResult DoTest()
        {
            MSProject.Application application = null;
            DateTime startTime = DateTime.Now;

            try
            {
                application = COMObject.Create <MSProject.Application>(COMObjectCreateOptions.CreateNewCore);

                MSProject.Project newProject = application.Projects.Add();

                newProject.Tasks.Add("Task 0");
                newProject.Tasks.Add("Task 1");
                newProject.Tasks.Add("Task 2");
                newProject.Tasks.Add("Task 3");
                newProject.Tasks.Add("Task 4");
                newProject.Tasks.Add("Task 5");
                newProject.Tasks.Add("Task 6");
                newProject.Tasks.Add("Task 7");
                newProject.Tasks.Add("Task 8");
                newProject.Tasks.Add("Task 9");

                return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, ""));
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                if (null != application)
                {
                    application.Quit(PjSaveType.pjDoNotSave);
                    application.Dispose();
                }
            }
        }
Beispiel #3
0
        public TestResult DoTest()
        {
            MSProject.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                application = new MSProject.Application();

                MSProject.Project newProject = application.Projects.Add();

                newProject.Tasks.Add("Task 0");
                newProject.Tasks.Add("Task 1");
                newProject.Tasks.Add("Task 2");
                newProject.Tasks.Add("Task 3");
                newProject.Tasks.Add("Task 4");
                newProject.Tasks.Add("Task 5");
                newProject.Tasks.Add("Task 6");
                newProject.Tasks.Add("Task 7");
                newProject.Tasks.Add("Task 8");
                newProject.Tasks.Add("Task 9");

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit(PjSaveType.pjDoNotSave);
                    application.Dispose();
                }
            }
        }
Beispiel #4
0
        public TestResult DoTest()
        {
            NetOffice.Settings.Default.MessageFilter.Enabled = true;
            MSProject.Application application = null;
            DateTime startTime = DateTime.Now;

            try
            {
                application = new MSProject.Application();

                application.ProjectTaskNewEvent          += new MSProject.Application_ProjectTaskNewEventHandler(ApplicationProjectTaskNewEvent);
                application.ProjectBeforeCloseEvent      += new MSProject.Application_ProjectBeforeCloseEventHandler(ApplicationProjectBeforeCloseEvent);
                application.ProjectBeforeTaskChangeEvent += new MSProject.Application_ProjectBeforeTaskChangeEventHandler(ApplicationProjectBeforeTaskChangeEvent);
                application.ProjectBeforeTaskDeleteEvent += new MSProject.Application_ProjectBeforeTaskDeleteEventHandler(ApplicationProjectBeforeTaskDeleteEvent);

                MSProject.Project newProject = application.Projects.Add();
                MSProject.Task    task1      = newProject.Tasks.Add("Task 1");
                MSProject.Task    task2      = newProject.Tasks.Add("Task 2");

                task2.Delete();

                application.FileCloseAll(PjSaveType.pjDoNotSave);

                if (TaskDeleteEventCalled && TaskChangeEventCalled && BeforeCloseEventCalled && TaskChangeEventCalled)
                {
                    return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, ""));
                }
                else
                {
                    string errorMessage = "";
                    if (!TaskDeleteEventCalled)
                    {
                        errorMessage += "ProjectBeforeTaskDeleteEvent failed ";
                    }
                    if (!TaskChangeEventCalled)
                    {
                        errorMessage += "ProjectBeforeTaskChangeEvent failed ";
                    }
                    if (!BeforeCloseEventCalled)
                    {
                        errorMessage += "ProjectBeforeCloseEvent failed ";
                    }
                    if (!TaskNewEventCalled)
                    {
                        errorMessage += "ProjectTaskNewEvent failed ";
                    }

                    return(new TestResult(false, DateTime.Now.Subtract(startTime), errorMessage, null, ""));
                }
            }
            catch (Exception exception)
            {
                return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""));
            }
            finally
            {
                NetOffice.Settings.Default.MessageFilter.Enabled = false;

                if (null != application)
                {
                    application.Quit(PjSaveType.pjDoNotSave);
                    application.Dispose();
                }
            }
        }