public void WslUtils_ConvertToDistroPath(string path, string expectedDistro, string expectedPath)
        {
            string actualPath = WslUtils.ConvertToDistroPath(path, out string actualDistro);

            Assert.Equal(expectedPath, actualPath);
            Assert.Equal(expectedDistro, actualDistro);
        }
        public override Process CreateProcess(string path, string args, bool useShellExecute, string workingDirectory)
        {
            // If we're asked to start a WSL executable we must launch via the wsl.exe command tool
            if (!useShellExecute && WslUtils.IsWslPath(path))
            {
                string wslPath = WslUtils.ConvertToDistroPath(path, out string distro);
                return(WslUtils.CreateWslProcess(distro, $"{wslPath} {args}", workingDirectory));
            }

            return(base.CreateProcess(path, args, useShellExecute, workingDirectory));
        }
        public void WslUtils_CreateWslProcess()
        {
            const string distribution = "ubuntu";
            const string command      = "/usr/lib/git-core/git version";

            string expectedFileName = WslUtils.GetWslPath();
            string expectedArgs     = $"--distribution {distribution} --exec {command}";

            Process process = WslUtils.CreateWslProcess(distribution, command);

            Assert.NotNull(process);
            Assert.Equal(expectedArgs, process.StartInfo.Arguments);
            Assert.Equal(expectedFileName, process.StartInfo.FileName);
            Assert.True(process.StartInfo.RedirectStandardInput);
            Assert.True(process.StartInfo.RedirectStandardOutput);
            Assert.True(process.StartInfo.RedirectStandardError);
            Assert.False(process.StartInfo.UseShellExecute);
        }
 public void WslUtils_ConvertToDistroPath_Invalid_ThrowsException(string path)
 {
     Assert.Throws <ArgumentException>(() => WslUtils.ConvertToDistroPath(path, out _));
 }
        public void WslUtils_IsWslPath(string path, bool expected)
        {
            bool actual = WslUtils.IsWslPath(path);

            Assert.Equal(expected, actual);
        }