Example #1
0
        public void TestExternalProcessRelativeApp()
        {
            var testFilePath = Path.Combine(m_ServHelper.WorkingDir, Guid.NewGuid().ToString() + ".txt");
            var content      = Guid.NewGuid().ToString();

            var srv = new ExternalProcessService(this.GetType().Assembly,
                                                 m_ServHelper.WorkingDir,
                                                 new ExternalProcessAttribute("ExternalApp.exe", $"\"{testFilePath}\" {content}"));

            srv.StartApplication();

            Thread.Sleep(200);

            Assert.IsTrue(File.Exists(testFilePath));
            Assert.AreEqual(content, File.ReadAllText(testFilePath));
        }
Example #2
0
        public void TestExternalServiceErrors()
        {
            var srv1 = new ExternalProcessService(this.GetType().Assembly,
                                                  m_ServHelper.WorkingDir,
                                                  new ExternalProcessAttribute("MissingApp.exe"));

            var testAppPath = Path.Combine(m_ServHelper.WorkingDir, Guid.NewGuid().ToString() + ".exe");

            File.WriteAllBytes(testAppPath, new byte[] { 1, 2, 3 });

            var srv2 = new ExternalProcessService(this.GetType().Assembly,
                                                  m_ServHelper.WorkingDir,
                                                  new ExternalProcessAttribute(testAppPath));

            Assert.ThrowsException <ExternalProcessNotFoundException>(() => srv1.StartApplication());
            Assert.ThrowsException <ExternalProcessStartException>(() => srv2.StartApplication());
        }