Exemple #1
0
    static void AssertProcess(bool isRunning, params FilePair[] pairs)
    {
        foreach (var pair in pairs)
        {
            var command = tool.BuildCommand(pair.Received, pair.Verified);
            if (isRunning == ProcessCleanup.IsRunning(command))
            {
                continue;
            }

            var    commands = string.Join(Environment.NewLine, ProcessCleanup.Commands.Select(x => x.Command));
            string message;
            if (isRunning)
            {
                message = "Expected command running";
            }
            else
            {
                message = "Expected command not running";
            }

            throw new Exception($@"{message}
{command}
Commands:
{commands}");
        }
    }
    public async Task LaunchAndKillDisabledAsync()
    {
        DiffRunner.Disabled = true;
        try
        {
            Assert.False(IsRunning());
            Assert.False(ProcessCleanup.IsRunning(command));
            var result = await DiffRunner.LaunchAsync(file1, file2);

            Assert.Equal(LaunchResult.Disabled, result);
            Thread.Sleep(500);
            ProcessCleanup.Refresh();
            Assert.False(IsRunning());
            Assert.False(ProcessCleanup.IsRunning(command));
            DiffRunner.Kill(file1, file2);
            Thread.Sleep(500);
            ProcessCleanup.Refresh();
            Assert.False(IsRunning());
            Assert.False(ProcessCleanup.IsRunning(command));
        }
        finally
        {
            DiffRunner.Disabled = false;
        }
    }
    public async Task LaunchAndKillAsync()
    {
        Assert.False(IsRunning());
        Assert.False(ProcessCleanup.IsRunning(command));
        var result = await DiffRunner.LaunchAsync(file1, file2);

        Assert.Equal(LaunchResult.StartedNewInstance, result);
        Thread.Sleep(500);
        ProcessCleanup.Refresh();
        Assert.True(IsRunning());
        Assert.True(ProcessCleanup.IsRunning(command));
        DiffRunner.Kill(file1, file2);
        Thread.Sleep(500);
        ProcessCleanup.Refresh();
        Assert.False(IsRunning());
        Assert.False(ProcessCleanup.IsRunning(command));
    }
Exemple #4
0
 static void AssertProcessNotRunning(string command)
 {
     Assert.False(ProcessCleanup.IsRunning(command));
 }