public void ImportTest() { //arrange FileWrapper fileWrapper = new FileWrapper("", ""); String regFile = GetRegFile(); //act: import fileWrapper.ImportFrom(regFile); //assert Assert.IsFalse(String.IsNullOrEmpty(fileWrapper.Path_ProgramFilesDir), "imported 64x value missing"); Assert.IsFalse(String.IsNullOrEmpty(fileWrapper.Path_ProgramFilesDir86), "imported 32x value missing"); //clean up after yourself FileInfo fileInfo = new FileInfo(regFile); if (fileInfo.Exists) fileInfo.Delete(); }
/// <summary> /// Call this after ReadCommandLineArguments() to execute the commands the user wants /// </summary> private void ProcessCommandLineArgs() { if (opts.Help) { opts.PrintUsage(); Environment.Exit(0); } if (opts.Version) { Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version); Environment.Exit(0); } if (!String.IsNullOrWhiteSpace(opts.Export)) { FileWrapper fileWrapper = new FileWrapper(Path_ProgramFilesDir, Path_ProgramFilesDir86); fileWrapper.ExportTo(opts.Export); } if (!String.IsNullOrWhiteSpace(opts.Import)) { FileWrapper fileWrapper = new FileWrapper(Path_ProgramFilesDir, Path_ProgramFilesDir86); fileWrapper.ImportFrom(opts.Import); if (IsAdminLevel()) { registry.ProgramFilesDir = Path_ProgramFilesDir; registry.ProgramFilesDir86 = Path_ProgramFilesDir86; } else { Console.WriteLine(@"E: Unable to change registry value."); Console.WriteLine(@"E: Application has no admin priviledge."); } } if (!String.IsNullOrWhiteSpace(opts.Change32)) { if (!Environment.Is64BitOperatingSystem) { Console.WriteLine(@"Attention! 32-bit-computers don't differenciate between 32 and 64 bit applications."); Console.WriteLine(@"Changing the x86 value is ignored on 32-bit machines. Please use the normal registry key instead"); } if (IsAdminLevel()) { registry.ProgramFilesDir86 = opts.Change32; } else { Console.WriteLine(@"E: Unable to change registry value."); Console.WriteLine(@"E: Application has no admin priviledge."); } } if (!String.IsNullOrWhiteSpace(opts.Change64)) { if (IsAdminLevel()) { registry.ProgramFilesDir = opts.Change64; } else { Console.WriteLine(@"E: Unable to change registry value."); Console.WriteLine(@"E: Application has no admin priviledge."); } } if (opts.NoPopup) RateThisPopup_WasAlreadyOpened = true; if (opts.IgnoreWin10) Win10PopupOpen = false; //Call this only after processing all other arguments if (opts.Quiet) Environment.Exit(0); }