public async void IsOutdatedErrorifmissingfile()
        {
            _sut.SetTargetFile(F.ke.FilePath);
            var resp = await _sut.TargetIsOutdated(new CancellationToken());

            resp.Should().BeFalse();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
                }
            };
        }
예제 #4
0
        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");
            };
        }