public void Should_be_able_to_get_the_file_url_from_the_update() { var reader = new AppcastReader(); Update update = reader.Read(@"Samples\zunesocialtagger.xml").First(); Assert.That(update.FileUrl, Is.EqualTo("http://cloud.github.com/downloads/leetreveil/Zune-Social-Tagger/Zune_Social_Tagger_1.2.zip")); }
public void Should_be_able_to_get_the_updates_file_size_from_the_update() { var reader = new AppcastReader(); Update update = reader.Read(@"Samples\zunesocialtagger.xml").First(); Assert.That(update.FileLength, Is.EqualTo(865843)); }
public void Should_be_able_to_get_the_version_no__from_the_update() { var reader = new AppcastReader(); Update update = reader.Read(@"Samples\zunesocialtagger.xml").First(); Assert.That(update.Version, Is.EqualTo(new Version(1, 2))); }
public void Should_be_able_to_get_the_title_from_the_update() { var reader = new AppcastReader(); Update update = reader.Read(@"Samples\zunesocialtagger.xml").First(); Assert.That(update.Title, Is.EqualTo("Zune Social Tagger")); }
public void Should_be_able_to_get_the_description_from_the_update() { var reader = new AppcastReader(); var updates = reader.Read(ZuneUpdateFeed); Assert.AreEqual(1, updates.Count()); Assert.AreEqual(".WMA Support and other minor bug fixes", updates.First().Description); }
/// <summary> /// Check for Updates /// </summary> /// <param name="callback"> /// The callback. /// </param> public void CheckForUpdates(Action<UpdateCheckInformation> callback) { ThreadPool.QueueUserWorkItem( delegate { try { string url = VersionHelper.Is64Bit() ? Constants.Appcast64 : Constants.Appcast32; var currentBuild = this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild); var skipBuild = this.userSettingService.GetUserSetting<int>( UserSettingConstants.Skipversion); // Initialize variables WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); var reader = new AppcastReader(); // Get the data, convert it to a string, and parse it into the AppcastReader reader.GetUpdateInfo(new StreamReader(response.GetResponseStream()).ReadToEnd()); // Further parse the information string build = reader.Build; int latest = int.Parse(build); int current = currentBuild; int skip = skipBuild; // If the user wanted to skip this version, don't report the update if (latest == skip) { var info = new UpdateCheckInformation { NewVersionAvailable = false }; callback(info); return; } var info2 = new UpdateCheckInformation { NewVersionAvailable = latest > current, DescriptionUrl = reader.DescriptionUrl, DownloadFile = reader.DownloadFile, Build = reader.Build, Version = reader.Version, }; callback(info2); } catch (Exception exc) { callback(new UpdateCheckInformation { NewVersionAvailable = false, Error = exc }); } }); }
/* * TODO: Refactor this to use Caliburn Invocation */ /// <summary> /// Begins checking for an update to HandBrake. /// </summary> /// <param name="callback"> /// The method that will be called when the check is finished. /// </param> /// <param name="debug"> /// Whether or not to execute this in debug mode. /// </param> /// <param name="url"> /// The url. /// </param> /// <param name="currentBuild"> /// The current Build. /// </param> /// <param name="skipBuild"> /// The skip Build. /// </param> public static void BeginCheckForUpdates(AsyncCallback callback, bool debug, string url, int currentBuild, int skipBuild) { ThreadPool.QueueUserWorkItem(delegate { try { // Initialize variables WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); AppcastReader reader = new AppcastReader(); // Get the data, convert it to a string, and parse it into the AppcastReader reader.GetUpdateInfo(new StreamReader(response.GetResponseStream()).ReadToEnd()); // Further parse the information string build = reader.Build; int latest = int.Parse(build); int current = currentBuild; int skip = skipBuild; // If the user wanted to skip this version, don't report the update if (latest == skip) { UpdateCheckInformation info = new UpdateCheckInformation { NewVersionAvailable = false }; callback(new UpdateCheckResult(debug, info)); return; } UpdateCheckInformation info2 = new UpdateCheckInformation { NewVersionAvailable = latest > current, DescriptionUrl = reader.DescriptionUrl, DownloadFile = reader.DownloadFile, Build = reader.Build, Version = reader.Version, }; callback(new UpdateCheckResult(debug, info2)); } catch (Exception exc) { callback(new UpdateCheckResult(debug, new UpdateCheckInformation { Error = exc })); } }); }