public void Initialize() { AssemblyInjector.Inject(); var appInfo = new AppInfo("test_url") { AppIconPath = "icon_path" }; _remoteContentDownloader = Substitute.For <IRemoteContentDownloader>(); _sut = new DownloadWindowViewModel(appInfo, Substitute.For <IDebuggingInfoLogger>(), _remoteContentDownloader); }
protected virtual async Task ShowDownloadWindow(Channel channel) { var viewModel = new DownloadWindowViewModel(AppInfo, _logger, RemoteContentDownloader); var artifactPath = CreateTempPath(channel.ArtifactUrl); var window = new DownloadWindow { DataContext = viewModel }; bool[] finishedDownloading = { false }; viewModel.ContinueWithInstallationCommand = new DelegateCommand(e => { _logger.Log("Continue after downloading artifact"); _analyticsLogger.LogContinueWithInstallation(); OnArtifactDownloadedEvent(new SingleEventArgs <string>(artifactPath)); window.Close(); if (ShouldOpenArtifact(channel, artifactPath)) { OpenArtifact(artifactPath); _logger.Log("Opened artifact"); } }, o => finishedDownloading[0]); SetOwner(window); OnWindowWillBeDisplayed(window, channel); window.Show(); var savedAt = await viewModel.StartAsync(channel, artifactPath).ConfigureAwait(true); finishedDownloading[0] = true; ((DelegateCommand)viewModel.ContinueWithInstallationCommand).RaiseCanExecuteChanged(); if (string.IsNullOrWhiteSpace(savedAt)) { window.Close(); ShowErrorWindow(); } }
protected virtual void ShowDownloadWindow(RemoteAppcast appcast) { var viewModel = new DownloadWindowViewModel(_appInfo, _logger, RemoteContentDownloader); var artifactPath = CreateTempPath(appcast.ArtifactUrl); var window = new DownloadWindow { DataContext = viewModel }; viewModel.ContinueWithInstallationCommand = new DelegateCommand(e => { _logger.Log("Continue after downloading artifact"); _analyticsLogger.LogContinueWithInstallation(); OnArtifactDownloadedEvent(new SingleEventArgs <string>(artifactPath)); window.Close(); if (ShouldOpenArtifact(appcast, artifactPath)) { OpenArtifact(artifactPath); _logger.Log("Opened artifact"); } }); SetOwner(window); viewModel.StartAsync(appcast, artifactPath); window.ShowDialog(); }