From 85b459665f5bc2a1e3ea44b5a261ec5b0ac4f89e Mon Sep 17 00:00:00 2001 From: reddyashish <43763136+reddyashish@users.noreply.github.com> Date: Tue, 11 Jul 2023 10:39:21 -0400 Subject: [PATCH] Remove duplicate visualization tests and fixes DYN-5962 (#14146) * Remove duplicate visualization tests * Update HelixImageComparisonTests.cs * Add try catch to handle exception crash --- src/DynamoCoreWpf/Controls/StartPage.xaml.cs | 31 ++++++++++++------- .../HelixImageComparisonTests.cs | 14 +++++++-- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/DynamoCoreWpf/Controls/StartPage.xaml.cs b/src/DynamoCoreWpf/Controls/StartPage.xaml.cs index 65931622923..53eeddeae02 100644 --- a/src/DynamoCoreWpf/Controls/StartPage.xaml.cs +++ b/src/DynamoCoreWpf/Controls/StartPage.xaml.cs @@ -368,25 +368,32 @@ private void RefreshFileList(ObservableCollection files, files.Clear(); foreach (var filePath in filePaths) { - var extension = Path.GetExtension(filePath).ToUpper(); - // If not extension specified and code reach here, this means this is still a valid file - // only without file type. Otherwise, simply take extension substring skipping the 'dot'. - var subScript = extension.IndexOf(".") == 0 ? extension.Substring(1) : ""; - var caption = Path.GetFileNameWithoutExtension(filePath); + try + { + var extension = Path.GetExtension(filePath).ToUpper(); + // If not extension specified and code reach here, this means this is still a valid file + // only without file type. Otherwise, simply take extension substring skipping the 'dot'. + var subScript = extension.IndexOf(".") == 0 ? extension.Substring(1) : ""; + var caption = Path.GetFileNameWithoutExtension(filePath); - files.Add(new StartPageListItem(caption) + files.Add(new StartPageListItem(caption) + { + ContextData = filePath, + ToolTip = filePath, + SubScript = subScript, + ClickAction = StartPageListItem.Action.FilePath + }); + } + catch (ArgumentException ex) { - ContextData = filePath, - ToolTip = filePath, - SubScript = subScript, - ClickAction = StartPageListItem.Action.FilePath - }); + DynamoViewModel.Model.Logger.Log("File path is not valid: " + ex.StackTrace); + } } } private void HandleRegularCommand(StartPageListItem item) { - var dvm = this.DynamoViewModel; + var dvm = this.DynamoViewModel; switch (item.ContextData) { diff --git a/src/VisualizationTests/HelixImageComparisonTests.cs b/src/VisualizationTests/HelixImageComparisonTests.cs index bc2771c0ebc..1fcf70580af 100644 --- a/src/VisualizationTests/HelixImageComparisonTests.cs +++ b/src/VisualizationTests/HelixImageComparisonTests.cs @@ -10,18 +10,26 @@ using System.Linq; using System.Reflection; using System.Windows.Media.Imaging; -using Dynamo.Graph.Nodes.ZeroTouch; +using Dynamo.Controls; using Dynamo.Selection; +using Dynamo.Utilities; using DynamoCoreWpfTests.Utility; using HelixToolkit.Wpf.SharpDX; using NUnit.Framework; namespace WpfVisualizationTests { - [TestFixture] - public class HelixImageComparisonTests : HelixWatch3DViewModelTests + public class HelixImageComparisonTests : VisualizationTest { + protected Watch3DView BackgroundPreview + { + get + { + return (Watch3DView)View.background_grid.Children().FirstOrDefault(c => c is Watch3DView); + } + } + #region utilities ///