public void Build_ValidParameters_FullPath() { var fileName = new RobotFileNameBuilder() .RobotDirectoryName(@"C:\foo\bar") .Version("5.3.9") .FileName("baz.qux") .Build(); Assert.AreEqual(@"C:\foo\bar\baz\v5.3.9\baz.qux", fileName); }
private static void LaunchRobot(string robotsDirectoryName, Process processInfo) { var latestVersion = RobotDirectory .GetVersions(RobotPath.Combine(robotsDirectoryName, processInfo.FileName)) .GetLatestVersion(); var robotFileName = new RobotFileNameBuilder() .RobotDirectoryName(robotsDirectoryName) .Version(latestVersion) .FileName(processInfo.FileName) .Build(); if (string.IsNullOrEmpty(robotFileName)) { throw new FileNotFoundException($"Robot not found '{robotFileName}'."); } if (IsRunning(processInfo.FileName, processInfo.Arguments)) { throw new InvalidOperationException($"Robot already running '{robotFileName}'."); } using (var process = System.Diagnostics.Process.Start(new ProcessStartInfo { FileName = robotFileName, Arguments = processInfo.Arguments, WindowStyle = processInfo.WindowStyle, //UseShellExecute = false, })) { if (process == null) { throw new ProcessNotStartedException(robotFileName); } LogEntry.New().Info().Message($"Started '{robotFileName}'").Log(Logger); using (var logEntry = LogEntry.New().Info().Stopwatch(sw => sw.Start()).AsAutoLog(Logger)) { process.WaitForExit(); if (process.ExitCode != 0) { logEntry.Error().Message($"'{robotFileName}' exited with error code {process.ExitCode}."); throw new ProcessTerminatedException($"'{robotFileName}' exited with error code {process.ExitCode}."); } logEntry.Info().Message($"'{robotFileName}' exited with error code {process.ExitCode}."); } } }