public ShowError ( string description ) : void | ||
description | string | |
Résultat | void |
public void SchedulerViewModel_AccountName_SetAccountName_IsDirty() { //------------Setup for test-------------------------- var _accountNameChanged = false; Mock<IEventAggregator> eventAggregator = new Mock<IEventAggregator>(); eventAggregator.Setup(c => c.Publish(It.IsAny<DebugOutputMessage>())).Verifiable(); var schedulerViewModel = new SchedulerViewModel(eventAggregator.Object, new Mock<DirectoryObjectPickerDialog>().Object, new Mock<IPopupController>().Object, new TestAsyncWorker(), new Mock<IConnectControlViewModel>().Object); var scheduledResourceForTest = new ScheduledResourceForTest(); schedulerViewModel.PropertyChanged += (sender, args) => { if(args.PropertyName == "AccountName") { _accountNameChanged = true; } }; schedulerViewModel.SelectedTask = scheduledResourceForTest; schedulerViewModel.ShowError("Error while saving: Logon failure: unknown user name or bad password"); Assert.AreEqual("Error while saving: Logon failure: unknown user name or bad password", schedulerViewModel.Error); //------------Execute Test--------------------------- schedulerViewModel.AccountName = "someAccountName"; //------------Assert Results------------------------- Assert.AreEqual("", schedulerViewModel.Error); Assert.IsTrue(schedulerViewModel.SelectedTask.IsDirty); Assert.AreEqual("someAccountName", schedulerViewModel.SelectedTask.UserName); Assert.IsTrue(_accountNameChanged); }
public bool SaveTasks() { if (_schedulerViewModel.CurrentEnvironment.IsConnected) { var authService = _schedulerViewModel.CurrentEnvironment.AuthorizationService; if (authService != null && authService.IsAuthorized(AuthorizationContext.Administrator, null)) { if (!ValidateSelectedTask()) { return(false); } GetCredentials(_schedulerViewModel.SelectedTask); string errorMessage; if (!_schedulerViewModel.ScheduledResourceModel.Save(_schedulerViewModel.SelectedTask, out errorMessage)) { _schedulerViewModel.ShowSaveErrorDialog(errorMessage); _schedulerViewModel.ShowError(errorMessage); return(false); } Dev2Logger.Info($"Save Schedule. Environment: {_schedulerViewModel.CurrentEnvironment.Name} Name:{(_schedulerViewModel.SelectedTask != null ? _schedulerViewModel.SelectedTask.Name : string.Empty)} "); if (_schedulerViewModel.SelectedTask != null) { _schedulerViewModel.SelectedTask.Errors.ClearErrors(); _schedulerViewModel.NotifyOfPropertyChange(() => _schedulerViewModel.Error); _schedulerViewModel.NotifyOfPropertyChange(() => _schedulerViewModel.Errors); _schedulerViewModel.SelectedTask.OldName = _schedulerViewModel.SelectedTask.Name; _schedulerViewModel.SelectedTask.IsNew = false; _schedulerViewModel.Item = _ser.Deserialize <IScheduledResource>(_ser.SerializeToBuilder(_schedulerViewModel.SelectedTask)); _schedulerViewModel.NotifyOfPropertyChange(() => _schedulerViewModel.IsDirty); } _schedulerViewModel.NotifyOfPropertyChange(() => _schedulerViewModel.TaskList); } else { _schedulerViewModel.ShowError(@"Error while saving: You don't have permission to schedule on this server. You need Administrator permission."); return(false); } return(true); } _schedulerViewModel.ShowError(Core.SchedulerNotConnectedErrorMessage); return(false); }
public void SchedulerViewModel_Password_SetPassword_IsDirty() { //------------Setup for test-------------------------- Mock<IEventAggregator> eventAggregator = new Mock<IEventAggregator>(); eventAggregator.Setup(c => c.Publish(It.IsAny<DebugOutputMessage>())).Verifiable(); var schedulerViewModel = new SchedulerViewModel(eventAggregator.Object, new Mock<DirectoryObjectPickerDialog>().Object, new Mock<IPopupController>().Object, new TestAsyncWorker(), new Mock<IConnectControlViewModel>().Object); var scheduledResourceForTest = new ScheduledResourceForTest(); schedulerViewModel.SelectedTask = scheduledResourceForTest; schedulerViewModel.ShowError("Error while saving: Logon failure: unknown user name or bad password"); Assert.AreEqual("Error while saving: Logon failure: unknown user name or bad password", schedulerViewModel.Error); //------------Execute Test--------------------------- schedulerViewModel.Password = "******"; //------------Assert Results------------------------- Assert.AreEqual("", schedulerViewModel.Error); Assert.IsTrue(schedulerViewModel.SelectedTask.IsDirty); }
public void SchedulerViewModel_ClearError_WithNormalError_HasErrorsSet() { //------------Setup for test-------------------------- var schedulerViewModel = new SchedulerViewModel(new Mock<IEventAggregator>().Object, new Mock<DirectoryObjectPickerDialog>().Object, new Mock<IPopupController>().Object, new TestAsyncWorker(), new Mock<IConnectControlViewModel>().Object) { SelectedTask = new ScheduledResourceForTest() }; var _hasErrorChange = false; var _errorChange = false; schedulerViewModel.ShowError("test error"); Assert.IsTrue(schedulerViewModel.HasErrors); schedulerViewModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) { switch(args.PropertyName) { case "HasErrors": _hasErrorChange = true; break; case "Error": _errorChange = true; break; } }; //------------Execute Test--------------------------- schedulerViewModel.ClearError("test error"); //------------Assert Results------------------------- Assert.IsTrue(_hasErrorChange); Assert.IsTrue(_errorChange); Assert.IsFalse(schedulerViewModel.HasErrors); }
public void SchedulerViewModel_ShowError_WithSaveError_HasErrorsTrue() { //------------Setup for test-------------------------- var schedulerViewModel = new SchedulerViewModel(new Mock<IEventAggregator>().Object, new Mock<DirectoryObjectPickerDialog>().Object, new Mock<IPopupController>().Object, new TestAsyncWorker(), new Mock<IConnectControlViewModel>().Object) { SelectedTask = new ScheduledResourceForTest() }; //------------Execute Test--------------------------- schedulerViewModel.ShowError("Error while saving: test error"); //------------Assert Results------------------------- Assert.IsTrue(schedulerViewModel.HasErrors); }