static IProgressNotifier DialogViewModel(Window owner, Action cancelAction) { var dialog = new ProgressDialog(owner); dialog.Closed += (sender, args) => cancelAction(); var dialogViewModel = new ProgressDialogViewModel(cancelAction, dialog.Show, dialog.Close); dialog.DataContext = dialogViewModel; return dialogViewModel; }
static IProgressNotifier DialogViewModel(Window owner, Action cancelAction) { var dialog = new ProgressDialog(owner); dialog.Closed += (sender, args) => cancelAction(); var dialogViewModel = new ProgressDialogViewModel(cancelAction, dialog.Show, dialog.Close); dialog.DataContext = dialogViewModel; return(dialogViewModel); }
public void ProgressDialogViewModel_Close_Executed_CallsCloseAction() { //------------Setup for test-------------------------- var closeActionCalled = false; var vm = new ProgressDialogViewModel(() => { }, () => { }, () => { closeActionCalled = true; }); //------------Execute Test--------------------------- vm.Close(); //------------Assert Results------------------------- Assert.IsTrue(closeActionCalled); }
public void ProgressDialogViewModel_CancelCommand_CancelCommandExecuted_CallsCancelAction() { //------------Setup for test-------------------------- bool cancelActionCalled = false; var vm = new ProgressDialogViewModel(() => { cancelActionCalled = true; }, () => { }, () => { }); //------------Execute Test--------------------------- vm.CancelCommand.Execute(null); //------------Assert Results------------------------- Assert.IsTrue(cancelActionCalled); }
void OpenServerLogFile(object o) { WebClient client = new WebClient { Credentials = CurrentEnvironment.Connection.HubConnection.Credentials }; var dialog = new ProgressDialog(); _progressDialogViewModel = new ProgressDialogViewModel(() => { dialog.Close(); }, delegate { dialog.Show(); }, delegate { dialog.Close(); }); _progressDialogViewModel.StatusChanged("Server Log File", 0, 0); _progressDialogViewModel.SubLabel = "Preparing to download Warewolf Server log file."; dialog.DataContext = _progressDialogViewModel; _progressDialogViewModel.Show(); client.DownloadProgressChanged += DownloadProgressChanged; client.DownloadFileCompleted += DownloadFileCompleted; var managementServiceUri = WebServer.GetInternalServiceUri("getlogfile", CurrentEnvironment.Connection); _serverLogFile = Path.Combine(GlobalConstants.TempLocation, CurrentEnvironment.Connection.DisplayName + " Server Log.txt"); client.DownloadFileAsync(managementServiceUri, _serverLogFile); }
public void ProgressDialogViewModel_StatusChanged_Exected_SetsLabelAndProgressValue() { //------------Setup for test-------------------------- var vm = new ProgressDialogViewModel(() => { }, () => { }, () => { }); //------------Execute Test--------------------------- const long totalBytes = 25895554; const int progressPercent = 85; vm.Label = "Warewolf.msi downloaded 60% of 25288 KB"; vm.ProgressValue = 60; vm.StatusChanged("Warewolf.msi", progressPercent , totalBytes); //------------Assert Results------------------------- Assert.AreEqual("Warewolf.msi downloaded 85% of 25288 KB", vm.Label); Assert.AreEqual(progressPercent, vm.ProgressValue); }
public void ProgressDialogViewModel_StartCancel_Exected_SetsSubLabelAndCancelButtonEnabled() { //------------Setup for test-------------------------- var vm = new ProgressDialogViewModel(() => { }, () => { }, () => { }); vm.SubLabel = "Downloading ..."; vm.IsCancelButtonEnabled = true; //------------Execute Test--------------------------- vm.StartCancel(); //------------Assert Results------------------------- Assert.AreEqual("Please wait while the process is being cancelled...", vm.SubLabel); Assert.IsFalse(vm.IsCancelButtonEnabled); }