public void TestOpenDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); object officeDocument = applicationController.OpenDocument(CopyFile(Path.Combine(m_testPath, "test.ppt")), false); Assert.IsNotNull(officeDocument); try { Assert.IsInstanceOf(typeof(PowerPoint.Presentation), officeDocument); } finally { if (null != officeDocument) Marshal.ReleaseComObject(officeDocument); officeDocument = null; } } }
public void TestQuit() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); Assert.IsTrue(applicationController.IsHostApplicationValid, "Expected a valid host application"); applicationController.Quit(); Assert.IsFalse(applicationController.IsHostApplicationValid, "Expected the host application to be invalid after a quit"); } }
public void TestRecoverInvalidHostApplication() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); PowerPoint._Application application = (PowerPoint._Application)applicationController.HostApplication; Assert.IsNotNull(application); Assert.IsTrue(applicationController.IsHostApplicationValid); // User kills all power point processes foreach (Process process in Process.GetProcessesByName("powerpnt")) { process.Kill(); } Assert.IsFalse(applicationController.IsHostApplicationValid); object officeDocument = applicationController.OpenDocument(CopyFile(Path.Combine(m_testPath, "test.ppt")), false); Assert.IsNotNull(officeDocument); Assert.IsTrue(applicationController.IsHostApplicationValid); application = (PowerPoint._Application)applicationController.HostApplication; try { Assert.AreEqual(1, application.Presentations.Count); Assert.IsInstanceOf(typeof(PowerPoint.Presentation), officeDocument); } finally { if (null != officeDocument) Marshal.ReleaseComObject(officeDocument); officeDocument = null; } } }
public void TestCloseNullDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); applicationController.CloseDocument(null, false); } }
public void TestCloseInvalidDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); applicationController.CloseDocument(new object(), false); } }
public void TestCloseDocumentOnAlreadyClosedDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); PowerPoint.Presentation presentation = (PowerPoint.Presentation) applicationController.OpenDocument(CopyFile(Path.Combine(m_testPath, "test.ppt")), false); Assert.IsNotNull(presentation); try { presentation.Close(); applicationController.CloseDocument(presentation, false); } finally { if (null != presentation) Marshal.ReleaseComObject(presentation); presentation = null; } } }
public void TestCloseDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); object officeDocument = applicationController.OpenDocument(CopyFile(Path.Combine(m_testPath, "test.ppt")), false); Assert.IsNotNull(officeDocument); PowerPoint.Presentations presentations = null; try { Assert.IsInstanceOf(typeof(PowerPoint.Presentation), officeDocument); PowerPoint._Application application = (PowerPoint._Application)applicationController.HostApplication; presentations = (PowerPoint.Presentations)application.Presentations; Assert.AreEqual(1, presentations.Count); applicationController.CloseDocument(officeDocument, false); Assert.AreEqual(0, presentations.Count); } finally { if (null != officeDocument) Marshal.ReleaseComObject(officeDocument); officeDocument = null; if (null != presentations) Marshal.ReleaseComObject(presentations); presentations = null; } } }
public void TestOpenDocumentInvalidHostApplication() { OfficeApplicationHelpers.SetTestSettings(1000, 2000, false, false, true, true, false); using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.OpenDocument(CopyFile(Path.Combine(m_testPath, "test.ppt")), false); } }
public void TestOpenDocumentMissingFile() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); applicationController.OpenDocument(m_testPath + "doesNotExist.ppt", false); } }
public void TestOpenInvalidDocument() { using (PowerPointApplicationController applicationController = new PowerPointApplicationController(true)) { applicationController.CreateHostApplication(2000); applicationController.OpenDocument(null, false); } }