public void ShouldUnzipDownloadedFile() { AutoUpdater.Initialize("http://update.arcnet.com.br/autoupdatereasytest/config.json", "1.0.0.0"); _percent = 0; AutoUpdater.Instance.DownloadProgressChanged += (e, a) => { Percent(a.ProgressPercentage); }; AutoUpdater.Instance.DownloadCompleted += (e, a) => { Debug.WriteLine("FIM DO DOWNLOAD"); }; AutoUpdater.Instance.Error += (e, a) => { Debug.WriteLine(a.Message); }; AutoUpdater.Instance.Join(); Assert.IsTrue(File.Exists($@".\{JsonConfig.Factory().PackageFileName}")); var form = new UiMain(); var uIMainLoad = form.GetType().GetMethod("UiMain_Load", BindingFlags.NonPublic | BindingFlags.Instance); var tmrMainTick = form.GetType().GetMethod("TmrMain_Tick", BindingFlags.NonPublic | BindingFlags.Instance); Assert.IsNotNull(uIMainLoad); Assert.IsNotNull(tmrMainTick); uIMainLoad.Invoke(form, new object[] { this, EventArgs.Empty }); try { tmrMainTick.Invoke(form, new object[] { this, EventArgs.Empty }); } catch (TargetInvocationException ex) { throw ex.InnerException; } }
public void ShouldDownloadFile() { AutoUpdater.Initialize("http://update.arcnet.com.br/autoupdatereasytest/config.json", "1.0.0.0"); _percent = 0; AutoUpdater.Instance.DownloadProgressChanged += (e, a) => { Percent(a.ProgressPercentage); }; AutoUpdater.Instance.DownloadCompleted += (e, a) => { Debug.WriteLine("FIM DO DOWNLOAD"); }; AutoUpdater.Instance.Error += (e, a) => { Debug.WriteLine(a.Message); }; AutoUpdater.Instance.Join(); Assert.IsTrue(File.Exists($@".\{JsonConfig.Factory().PackageFileName}")); }
private AutoUpdater(string url, string currentVersion) { _url = url; _currentVersion = currentVersion; _jsonConfig = JsonConfig.Factory(); }
private void Run() { try { _isRunning = true; while (!_isCancel) { try { _jsonConfig = JsonConfig.Factory(_url); _jsonConfig.Save(); if (!_jsonConfig.IsNewVersion(_currentVersion)) { Sleep(_jsonConfig.GetMilliseconds() / 1000); continue; } if (!_jsonConfig.ForceUpdate) { _await = true; OnNewUpdate(); Waiting(); if (!_isAccepted) { Sleep(_jsonConfig.GetMilliseconds() / 1000); continue; } } _progress = 0; _jsonConfig.ProgressChanged += (e, a) => OnDownloadProgressChanged(a); _jsonConfig.DownloadCompleted += (e, a) => OnDownloadCompleted(); _await = true; _jsonConfig.Download(); Waiting(); if (_progress != 100) { continue; } _isCancel = true; } catch (DnsNotResolveException ex) { Sleep(_jsonConfig.GetMilliseconds() / 1000); OnError(ex.Message); } catch (ProtocolErrorException ex) { Sleep(_jsonConfig.GetMilliseconds() / 1000); OnError(ex.Message); } catch (ConnectionFailureException ex) { Sleep(_jsonConfig.GetMilliseconds() / 1000); OnError(ex.Message); } catch (Exception ex) { Sleep(_jsonConfig.GetMilliseconds() / 1000); OnError(ex.Message); } } } catch (ThreadAbortException) { _isRunning = false; } catch (ThreadInterruptedException) { _isRunning = false; } _isRunning = false; }
public void DnsNotResolve() { JsonConfig.Factory("http://update1.arcnet.com.br/autoupdatereasytest/myjsonupdater1.json"); }
public void JsonNotFound() { JsonConfig.Factory("http://update.arcnet.com.br/autoupdatereasytest/config1.json"); }
public void ShouldFactoryAClass() { var file = JsonConfig.Factory("http://update.arcnet.com.br/autoupdatereasytest/config.json"); Assert.IsNotNull(file); }