/// <summary> /// Invokes the action as a result of a ribbon control being clicked, selected, etc. /// </summary> /// <param name="ribbonControlId"> /// The Id property of the associated RibbonControl /// </param> /// <param name="ribbonControlTag"> /// The Tag property of the associated RibbonControl /// </param> public override async Task OnAction(string ribbonControlId, string ribbonControlTag = "") { IDialogNavigationService dialogService; switch (ribbonControlId) { case "CDP4_Open": dialogService = ServiceLocator.Current.GetInstance <IDialogNavigationService>(); var dataSelection = new DataSourceSelectionViewModel(); var dataSelectionResult = dialogService.NavigateModal(dataSelection) as DataSourceSelectionResult; break; case "CDP4_Close": await this.session.Close(); break; case "CDP4_ProxySettings": dialogService = ServiceLocator.Current.GetInstance <IDialogNavigationService>(); var proxyServerViewModel = new ProxyServerViewModel(); var proxyServerViewModelResult = dialogService.NavigateModal(proxyServerViewModel) as DataSourceSelectionResult; break; default: logger.Debug("The ribbon control with Id {0} and Tag {1} is not handled by the current RibbonPart", ribbonControlId, ribbonControlTag); break; } }
public void AssertThatProxyManagerDoesNotThrow() { var viewmodel = new DataSourceSelectionViewModel(this.navService.Object); Assert.IsTrue(viewmodel.OpenProxyConfigurationCommand.CanExecute(null)); Assert.DoesNotThrow(() => viewmodel.OpenProxyConfigurationCommand.Execute(null)); }
public void VerifyThatCancelWorks() { var viewmodel = new DataSourceSelectionViewModel(this.navService.Object); viewmodel.CancelCommand.Execute(null); Assert.IsFalse(viewmodel.HasError); }
public void AssertViewModelWorksWithMultipleUris() { var viewmodel = new DataSourceSelectionViewModel(this.navService.Object); Assert.IsTrue(viewmodel.CancelCommand.CanExecute(null)); Assert.That(viewmodel.ErrorMessage, Is.Null.Or.Empty); Assert.IsNotEmpty(viewmodel.AvailableDataSourceKinds); viewmodel.UserName = "******"; viewmodel.Password = "******"; var daltype0 = viewmodel.AvailableDataSourceKinds[0]; var daltype1 = viewmodel.AvailableDataSourceKinds[1]; viewmodel.SelectedDataSourceKind = null; UriConfig cl1 = new UriConfig() { Alias = "BadAlias", Uri = "KKK", DalType = daltype0.DalType.ToString() }; UriRowViewModel row1 = new UriRowViewModel() { UriConfig = cl1 }; UriConfig cl2 = new UriConfig() { Uri = "http://www.rheagroup.com", DalType = daltype0.DalType.ToString() }; UriRowViewModel row2 = new UriRowViewModel() { UriConfig = cl2 }; UriConfig cl3 = new UriConfig() { Uri = "http://www.rheagroup.com", DalType = daltype1.DalType.ToString() }; UriRowViewModel row3 = new UriRowViewModel() { UriConfig = cl3 }; viewmodel.AllDefinedUris.Clear(); viewmodel.AllDefinedUris.Add(row1); viewmodel.AllDefinedUris.Add(row2); viewmodel.AllDefinedUris.Add(row3); viewmodel.SelectedDataSourceKind = daltype0; viewmodel.SelectedUri = viewmodel.AvailableUris.Last(); Assert.IsTrue(viewmodel.OkCommand.CanExecute(null)); Assert.IsTrue(viewmodel.AvailableUris.Count == 2); viewmodel.SelectedDataSourceKind = daltype1; Assert.IsTrue(viewmodel.AvailableUris.Count == 1); }
public void AssertThatShowPasswordButtonTextMatchesState() { var viewmodel = new DataSourceSelectionViewModel(this.navService.Object); // When password is hidden button should be Show viewmodel.IsPasswordVisible = false; Assert.AreEqual(viewmodel.ShowPasswordButtonText, "Show"); // When password is visible it should show Hide viewmodel.IsPasswordVisible = true; Assert.AreEqual(viewmodel.ShowPasswordButtonText, "Hide"); }
/// <summary> /// Executes the <see cref="OpenDataSourceCommand"/> /// </summary> private void ExecuteOpenDataSourceRequest() { var openSessions = this.Sessions.Select(x => x.Session).ToList(); var dataSelection = new DataSourceSelectionViewModel(this.dialogNavigationService, openSessions); var result = this.dialogNavigationService.NavigateModal(dataSelection) as DataSourceSelectionResult; if (result == null || !result.Result.HasValue || !result.Result.Value) { return; } this.Sessions.Add(new SessionViewModel(result.Session)); this.SelectedSession = this.Sessions.First(); }
public void VerifyThatIfDuplicateSessionExistsErrorExists() { var sessions = new List <ISession>(); sessions.Add(this.session.Object); var viewmodel = new DataSourceSelectionViewModel(sessions); viewmodel.UserName = "******"; viewmodel.Password = "******"; viewmodel.Uri = "http://www.rheagroup.com"; viewmodel.OkCommand.Execute(null); Assert.AreEqual("A session with the username John already exists", viewmodel.ErrorMessage); }
/// <summary> /// Invokes the action as a result of a ribbon control being clicked, selected, etc. /// </summary> /// <param name="ribbonControlId"> /// The Id property of the associated RibbonControl /// </param> /// <param name="ribbonControlTag"> /// The Tag property of the associated RibbonControl /// </param> public override async Task OnAction(string ribbonControlId, string ribbonControlTag = "") { switch (ribbonControlId) { case "CDP4_Open": var dataSelection = new DataSourceSelectionViewModel(this.DialogNavigationService); var dataSelectionResult = this.DialogNavigationService.NavigateModal(dataSelection) as DataSourceSelectionResult; if (dataSelectionResult?.OpenModel ?? false) { this.OpenModelDialog(); } break; case "CDP4_Close": await this.session.Close(); break; case "CDP4_ProxySettings": var proxyServerViewModel = new ProxyServerViewModel(); var proxyServerViewModelResult = this.DialogNavigationService.NavigateModal(proxyServerViewModel) as DataSourceSelectionResult; break; case "CDP4_SelectModelToOpen": this.OpenModelDialog(); break; case "CDP4_SelectModelToClose": var sessionsClosing = new List <ISession> { this.session }; var modelClosingDialogViewModel = new ModelClosingDialogViewModel(sessionsClosing); var modelClosingDialogViewModelResult = this.DialogNavigationService.NavigateModal(modelClosingDialogViewModel) as DataSourceSelectionResult; break; case "CDP4_Plugins": var modelPluginDialogViewModel = new PluginManagerViewModel <AddinAppSettings>(this.appSettingService); var modelPluginDialogResult = this.DialogNavigationService.NavigateModal(modelPluginDialogViewModel) as DataSourceSelectionResult; break; default: logger.Debug("The ribbon control with Id {0} and Tag {1} is not handled by the current RibbonPart", ribbonControlId, ribbonControlTag); break; } }
public void Verify_that_when_proxy_is_enabled_proxy_address_and_port_are_set() { var vm = new DataSourceSelectionViewModel(this.navService.Object); Assert.IsFalse(vm.IsProxyEnabled); Assert.AreEqual(string.Empty, vm.ProxyUri); Assert.AreEqual(string.Empty, vm.ProxyPort); vm.IsProxyEnabled = true; Assert.AreNotEqual(string.Empty, vm.ProxyUri); Assert.AreNotEqual(string.Empty, vm.ProxyPort); vm.IsProxyEnabled = false; Assert.AreEqual(string.Empty, vm.ProxyUri); Assert.AreEqual(string.Empty, vm.ProxyPort); }
public void AssertThatOkCommandCanExecuteAndASessionObjectIsSet() { var viewmodel = new DataSourceSelectionViewModel(this.navService.Object); Assert.IsTrue(viewmodel.CancelCommand.CanExecute(null)); Assert.That(viewmodel.ErrorMessage, Is.Null.Or.Empty); Assert.IsNotEmpty(viewmodel.AvailableDataSourceKinds); viewmodel.UserName = "******"; viewmodel.Password = "******"; viewmodel.Uri = "http://www.rheagroup.com"; Assert.IsTrue(viewmodel.OkCommand.CanExecute(null)); viewmodel.OkCommand.Execute(null); Assert.NotNull(viewmodel.SelectedDataSourceKind); Assert.False(viewmodel.BrowseSourceCommand.CanExecute(null)); viewmodel.SelectedDataSourceKind = viewmodel.AvailableDataSourceKinds.Single(x => x.DalType == DalType.File); Assert.IsTrue(viewmodel.BrowseSourceCommand.CanExecute(null)); }