public void VerifyThatOkCommandWorks() { var application = new Application(); var workbook = application.Workbooks.Open(this.excelFilePath, false, false); Assert.NotNull(workbook); var viewModel = new CrossViewDialogViewModel(application, this.iteration, this.session.Object, workbook); Assert.IsInstanceOf <ElementDefinitionSelectorViewModel>(viewModel.ElementSelectorViewModel); Assert.IsInstanceOf <ParameterTypeSelectorViewModel>(viewModel.ParameterSelectorViewModel); Assert.DoesNotThrow(() => viewModel.ElementSelectorViewModel.BindData()); Assert.DoesNotThrow(() => viewModel.ParameterSelectorViewModel.BindData()); Assert.DoesNotThrow(() => viewModel.OkCommand.Execute(null)); Assert.IsTrue(viewModel.DialogResult.Result); workbook.Close(); workbook.Dispose(); application.Quit(); application.Dispose(); }
public void VerifyThatCancelCommandWorks() { var viewModel = new CrossViewDialogViewModel(null, this.iteration, this.session.Object, null); Assert.DoesNotThrow(() => viewModel.CancelCommand.Execute(null)); Assert.IsFalse(viewModel.DialogResult.Result); }
private async Task LaunchCrossViewEditorAsync(string iterationId) { if (iterationId == string.Empty) { Logger.Debug("The cross editor workbook cannot be build: the iteration id is empty"); return; } var uniqueId = Guid.Parse(iterationId); var iteration = this.Iterations.SingleOrDefault(x => x.Iid == uniqueId); if (iteration == null) { Logger.Debug($"The cross editor workbook cannot be build: iteration {uniqueId} cannot be found"); return; } if (!(iteration.Container is EngineeringModel engineeringModel)) { Logger.Error("The cross editor workbook cannot be build: Iteration container object is null"); return; } var activeParticipant = engineeringModel.EngineeringModelSetup.Participant.FirstOrDefault(x => x.Person == this.Session.ActivePerson); if (this.officeApplicationWrapper.Excel == null) { Logger.Error("The cross editor workbook cannot be build: The Excel Application object is null"); return; } var activeWorkbook = this.ExcelQuery.QueryActiveWorkbook(this.officeApplicationWrapper.Excel); var crossViewDialogViewModel = new CrossViewDialogViewModel(this.officeApplicationWrapper.Excel, iteration, this.Session, activeWorkbook); this.DialogNavigationService.NavigateModal(crossViewDialogViewModel); var dialogResult = crossViewDialogViewModel.DialogResult as WorkbookSelectionDialogResult; if (dialogResult?.Result != null && dialogResult.Result.Value) { var workbook = dialogResult.Workbook; var workbookMetadata = new WorkbookMetadata { ElementDefinitions = dialogResult.WorkbookElements.Select(x => x.Iid), ParameterTypes = dialogResult.WorkbookParameterType.Select(x => x.Iid), ParameterValues = dialogResult.WorkbookChangedValues, PersistValues = dialogResult.PersistValues }; var workbookOperator = new WorkbookOperator(this.officeApplicationWrapper.Excel, workbook, workbookMetadata); await workbookOperator.Rebuild(this.Session, iteration, activeParticipant); } }
public void VerifyThatPropertiesAreSet() { var viewModel = new CrossViewDialogViewModel(null, this.iteration, this.session.Object, null); Assert.AreEqual("Select ElementDefinitions and ParameterTypes", viewModel.DialogTitle); Assert.IsInstanceOf <ElementDefinitionSelectorViewModel>(viewModel.ElementSelectorViewModel); Assert.IsInstanceOf <ParameterTypeSelectorViewModel>(viewModel.ParameterSelectorViewModel); Assert.AreEqual(true, viewModel.PersistValues); Assert.DoesNotThrow(() => viewModel.ElementSelectorViewModel.BindData()); Assert.DoesNotThrow(() => viewModel.ParameterSelectorViewModel.BindData()); }
public void VerifyThatOkCommandWorksWithNullWorkbook() { var viewModel = new CrossViewDialogViewModel(null, this.iteration, this.session.Object, null); Assert.IsInstanceOf <ElementDefinitionSelectorViewModel>(viewModel.ElementSelectorViewModel); Assert.IsInstanceOf <ParameterTypeSelectorViewModel>(viewModel.ParameterSelectorViewModel); Assert.DoesNotThrow(() => viewModel.ElementSelectorViewModel.BindData()); Assert.DoesNotThrow(() => viewModel.ParameterSelectorViewModel.BindData()); Assert.DoesNotThrow(() => viewModel.OkCommand.Execute(null)); Assert.IsTrue(viewModel.DialogResult.Result); }