Ejemplo n.º 1
0
 public void ShouldAllowKillingTreeWhenRunInBackground()
 {
     SystemAssert.AssertProcessKilled("ping", () =>
     {
         var process = new ProcessRunner().Start("cmd /c cmd /c ping 127.0.0.1 -n 20");
         Assert.That(process.WasKilled, Is.False);
         process.KillTree();
         Assert.That(process.WasKilled, Is.True);
     });
 }
Ejemplo n.º 2
0
 public void ShouldReportTimeoutWhenKilled()
 {
     var process = new ProcessRunner().Start("ping 127.0.0.1 -n 20");
     process.KillTree();
     Assert.That(process.ToString(), Is.EqualTo("<ping 127.0.0.1 -n 20> timed out"));
 }
Ejemplo n.º 3
0
 public void ShouldReportCommandLineBeforeProcessExits()
 {
     var process = new ProcessRunner().Start("ping 127.0.0.1 -n 20");
     Assert.That(process.ToString(), Is.EqualTo("<ping 127.0.0.1 -n 20>"));
     process.KillTree();
 }
Ejemplo n.º 4
0
        public void ShouldCreateSelfExtractingExecutableThatRunsTheDeployer()
        {
            Using.Directory("deployer-test", () =>
            {
                File.WriteAllText("test.proj", @"
                    <Project DefaultTargets='Build' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                      <PropertyGroup>
                        <PackageName>DeployerTest</PackageName>
                        <CMDirectory>$(MSBuildProjectDirectory)\..\CM.NET</CMDirectory>
                      </PropertyGroup>

                      <Import Project='$(CMDirectory)\Default.targets' />
                      <Import Project='$(CMDirectory)\Packagers\Deployer\Deployer.targets' />
                    </Project>");

                var output = Shell.MSBuild("test.proj", TimeSpan.FromSeconds(30));

                Assert.That(File.Exists(@"build\sfx\DeployerTest.exe"), output);
                var process = new ProcessRunner().Start(@"build\sfx\DeployerTest.exe");
                try
                {
                    Assert.That(WaitForProcess("deployer"), Is.Not.Null, "no deployer process is running");
                }
                finally
                {
                    process.KillTree();
                }
            });
        }