public async void IsOutdatedErrorifmissingfile() { _sut.SetTargetFile(F.ke.FilePath); var resp = await _sut.TargetIsOutdated(new CancellationToken()); resp.Should().BeFalse(); }
public async void UpdateRunningExe() { var proc = TestClient.Run(); var exePath = proc.StartInfo.FileName; var localPkg = LocalR2Package.From(exePath); var evtRaisd = false; localPkg.nid = 29; Assert.Throws <UnauthorizedAccessException>(() => File.Delete(exePath)); _downldr.SetTargetFile(exePath); var isOld = await _downldr.TargetIsOutdated(new CancellationToken()); isOld.Should().BeTrue("test should start with outdated target"); _downldr.TargetUpdated += (s, e) => evtRaisd = true; await _downldr.UpdateTarget(new CancellationToken()); isOld = await _downldr.TargetIsOutdated(new CancellationToken()); isOld.Should().BeFalse("target should now be up-to-date"); evtRaisd.Should().BeTrue(); proc.Kill(); }
public R2AppUpdaterBase(ILocalPackageFileUpdater localPackageFileUpdater, IFileSystemAccesor fileSystemAccesor) { _fs = fileSystemAccesor; _r2Upd8r = localPackageFileUpdater; _r2Upd8r.SetTargetFile(_fs.CurrentExeFile); _r2Upd8r.StatusChanged += (s, e) => SetStatus(e); _r2Upd8r.TargetUpdated += (s, e) => _updatesInstalled?.Raise(); RelaunchCmd = R2Command.Relay(RelaunchApp); RelaunchCmd.OverrideEnabled = false; StatusChanged += (s, e) => { Logs.Add(e); LogText = string.Join(L.f, Logs); }; Logs.MaxCount = 20; UpdatesInstalled += (s, e) => { OnUpdateInstalled?.Invoke(); RelaunchCmd.OverrideEnabled = true; CommandManager.InvalidateRequerySuggested(); if (AutoRelaunchOnUpdate) { RelaunchCmd.ExecuteIfItCan(); } }; }
private void InitializeUpdater(ILifetimeScope scope) { _upd8r = scope.Resolve <ILocalPackageFileUpdater>(); _upd8r.SetTargetFile(Assembly.GetEntryAssembly().Location); _upd8r.StatusChanged += (s, statusText) => { Status += $"{L.f}{statusText}"; IsChecking = _upd8r.IsChecking; }; _upd8r.TargetUpdated += (s, e) => { Status += $"{L.F}[event] Target Updated."; RelaunchCmd = R2Command.Relay(RelaunchApp, x => true, "Relaunch Now"); }; }