public static void Main(string[] args) { // Try processing the standalone arguments if (ProcessStandaloneArguments(args)) return; // Try processing the common arguments (bool success, MediaType mediaType, RedumpSystem? knownSystem) = ProcessCommonArguments(args); if (!success) return; // Loop through and process options (Options options, string path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2); // Make new Progress objects var resultProgress = new Progress<Result>(); resultProgress.ProgressChanged += ProgressUpdated; var protectionProgress = new Progress<ProtectionProgress>(); protectionProgress.ProgressChanged += ProgressUpdated; // Validate the supplied credentials (bool? _, string message) = RedumpWebClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword); if (!string.IsNullOrWhiteSpace(message)) Console.WriteLine(message); // Loop through all the rest of the args for (int i = startIndex; i < args.Length; i++) { // Check for a file if (!File.Exists(args[i].Trim('"'))) { DisplayHelp($"{args[i].Trim('"')} does not exist"); return; } // Get the full file path string filepath = Path.GetFullPath(args[i].Trim('"')); // Now populate an environment Drive drive = null; if (!string.IsNullOrWhiteSpace(path)) drive = Drive.Create(null, path); var env = new DumpEnvironment(options, "", filepath, drive, knownSystem, mediaType, null); // Finally, attempt to do the output dance var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(result.Message); } }
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType?mediaType, bool expected) { var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator }; // TODO: This relies on creating real objects for the drive. Can we mock this out instead? var drive = isFloppy ? Drive.Create(InternalDriveType.Floppy, letter.ToString()) : Drive.Create(InternalDriveType.Optical, letter.ToString()); var env = new DumpEnvironment(options, string.Empty, string.Empty, drive, RedumpSystem.IBMPCcompatible, mediaType, parameters); bool actual = env.ParametersValid(); Assert.Equal(expected, actual); }