From 30cb7e62fde4b878ce0fb8bf45402be617a438b4 Mon Sep 17 00:00:00 2001 From: Lavius Motileng <58791731+laviusmotileng-ms@users.noreply.github.com> Date: Thu, 4 Jun 2020 11:05:28 -0700 Subject: [PATCH] removed restrictions for image-resizer file format (#3377) --- .../ViewModels/ImageResizerViewModel.cs | 5 +-- .../ViewModelTests/ImageResizer.cs | 32 ------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/ImageResizerViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/ImageResizerViewModel.cs index f5d7de86d5..b63c7b21a5 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/ImageResizerViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/ImageResizerViewModel.cs @@ -178,10 +178,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels set { - var regex = @"[%]{1}[1-6]{1} [(]{1}[%]{1}[1-6]{1}[)]{1}"; - Match match = Regex.Match(value.Trim(), regex); - - if (!string.IsNullOrWhiteSpace(value) && match.Success) + if (!string.IsNullOrWhiteSpace(value)) { _fileName = value; Settings.Properties.ImageresizerFileName.Value = value; diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/ImageResizer.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/ImageResizer.cs index f1e7f09c5f..fd3e1f3409 100644 --- a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/ImageResizer.cs +++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/ImageResizer.cs @@ -124,38 +124,6 @@ namespace ViewModelTests Assert.AreEqual(expectedValue, viewModel.FileName); } - [TestMethod] - public void FileName_ShouldNOTUpdateValue_WhenNameIsInValid () - { - // arrange - ImageResizerViewModel viewModel = new ImageResizerViewModel(); - string[] invalidNames = - { - string.Empty, - " ", // no name. - "%1", // single name value. - "%7 (%5)", // name max index exceeded. - "%8 (%8)", // name max index exceeded. - "%5 (%3 )", // name contains extra spaces. - "%5 (%3)", // name contains extra spaces. - "%5 ( %3)", // name contains extra spaces. - "% 5 ( %3)", // name contains extra spaces. - "%5 (% 3)", // name contains extra spaces. - "%5 ( %3 )", // name contains extra spaces. - }; - - // act and Assert - foreach (string invalidName in invalidNames) - { - viewModel = new ImageResizerViewModel(); - viewModel.FileName = invalidName; - Assert.AreNotEqual(invalidName, viewModel.FileName); - - ImageResizerSettings settings = SettingsUtils.GetSettings(Module); - Assert.AreNotEqual(invalidName, settings.Properties.ImageresizerFileName.Value); - } - } - [TestMethod] public void KeepDateModified_ShouldUpdateValue_WhenSuccessful() {