public UpdateHandler(IMessenger messenger, LiveProgramInfo programInfo, IReceiveUserInput inputReceiver , IInstallUpdates updateInstaller, Locator locator) { this.messenger = messenger; this.programInfo = programInfo; this.inputReceiver = inputReceiver; this.updateInstaller = updateInstaller; this.locator = locator; }
public void Test_UpdaterPathFinder_CannotAccessAppData() { List <UpdatePackageData> packages = new List <UpdatePackageData> { new UpdatePackageData { PublicId = this.PrgPkg_4, Version = "3.5", FileName = "Updates.zip" } , new UpdatePackageData { PublicId = this.PrgPkg_2, Version = "2.0", FileName = "Updates.zip" } , new UpdatePackageData { PublicId = this.PrgPkg_1, Version = "1.0", FileName = "Updates.zip" } , new UpdatePackageData { PublicId = this.PrgPkg_3, Version = "3.0", FileName = "Updates.zip" } }; string temp = Path.GetTempPath(); string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(appData, "Telimena", "Test_UpdaterPathFinder_CannotAccessAppData")); dirInfo.Create(); DirectorySecurity securityRules = new DirectorySecurity(); securityRules.AddAccessRule(new FileSystemAccessRule("Users", FileSystemRights.Write, AccessControlType.Deny)); dirInfo.SetAccessControl(securityRules); var lpi = new LiveProgramInfo(new ProgramInfo { Name = "Test_UpdaterPathFinder_CannotAccessAppData" }) { UpdaterName = "MyUpdater.exe" }; Locator locator = new Locator(lpi.Program, temp); FileInfo updater = locator.GetUpdater(lpi); Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\MyUpdater.exe", updater.FullName); DirectoryInfo subFolder = locator.GetCurrentUpdateSubfolder(packages); Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5", subFolder.FullName); Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5\3.5\Updates.zip", locator.BuildUpdatePackagePath(subFolder, packages[0]).FullName); Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5\2.0\Updates.zip", locator.BuildUpdatePackagePath(subFolder, packages[1]).FullName); }
public void Test_UpdaterPathFinder() { string temp = Path.GetTempPath(); string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var lpi = new LiveProgramInfo(new ProgramInfo { Name = "Test_UpdaterPathFinder" }) { UpdaterName = "MyUpdater.exe" }; Locator locator = new Locator(lpi.Program, temp); FileInfo updater = locator.GetUpdater(lpi); Assert.AreEqual($@"{appData}\Telimena\Test_UpdaterPathFinder\Updates\MyUpdater.exe", updater.FullName); }
public bool ShowInstallUpdatesNowQuestion(string maxVersion, long totalDownloadSize, LiveProgramInfo programInfo) { var currentColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"An update to version {maxVersion} is downloaded and available for immediate installation (total size: {totalDownloadSize.GetSizeString()})." + $"\r\nWould you like to install now?" + $"\r\n[Y]es / [N]o"); ConsoleKeyInfo choice = Console.ReadKey(); while (choice.Key != ConsoleKey.Y && choice.Key != ConsoleKey.N) { Console.WriteLine("Invalid choice. Press Y for [Y]es or N for [N]o"); choice = Console.ReadKey(); } Console.ForegroundColor = currentColor; return(choice.Key == ConsoleKey.Y); }
public bool ShowInstallUpdatesNowQuestion(string maxVersion, long totalDownloadSize, LiveProgramInfo programInfo) { MessageBoxResult choice = MessageBox.Show($"An update to version {maxVersion} was downloaded.\r\nWould you like to install now?" , $"{programInfo.Program.Name} update installation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (choice == MessageBoxResult.Yes) { return(true); } return(false); }
public bool ShowDownloadAndInstallUpdatesQuestion(string maxVersion, long totalDownloadSize, LiveProgramInfo programInfo) { MessageBoxResult choice = MessageBox.Show($"An update to version {maxVersion} is available\r\n" + $"Total download size: {totalDownloadSize.GetSizeString(2)}.\r\n" + $"Would you like to download and install now?" , $"{programInfo.Program.Name} update download", MessageBoxButton.YesNo, MessageBoxImage.Question); if (choice == MessageBoxResult.Yes) { return(true); } return(false); }
public FileInfo GetUpdater(LiveProgramInfo liveProgramInfo) { return(new FileInfo(Path.Combine(this.GetUpdatesParentFolder().FullName, liveProgramInfo.UpdaterName))); }