From f642da28fbb92bb4887858598dacf26b45d590ed Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Mon, 9 Jan 2023 12:03:39 +0100 Subject: [PATCH] Dry repetitive code even more! Makes comments superfluous --- ...sualVerificationUITestContextExtensions.cs | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs index c33d2daf5..d1fffe698 100644 --- a/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/VisualVerificationUITestContextExtensions.cs @@ -400,13 +400,7 @@ private static void AssertVisualVerification( using var elementImageOriginal = context.TakeElementScreenshot(element).ShouldNotBeNull(); var originalElementScreenshotFileName = - new[] - { - configuration.FileNamePrefix, - VisualVerificationMatchNames.ElementImageFileName, - configuration.FileNameSuffix, - } - .JoinNotNullOrEmpty("-"); + configuration.WrapFileName(VisualVerificationMatchNames.ElementImageFileName); // Checking the dimensions of captured image. This needs to happen before any other comparisons, because that // can only be done on images with the same dimensions. @@ -458,25 +452,14 @@ private static void AssertVisualVerification( catch { // Here we append all the relevant items to the failure dump to help the investigation. - void AddImageToFailureDumpLocal(string fileName, Image image) => - context.AddImageToFailureDump(configuration.WrapFileName(fileName), image); + void AddImageToFailureDumpLocal(string fileName, Image image, bool dontWrap = false) => + context.AddImageToFailureDump(dontWrap ? fileName : configuration.WrapFileName(fileName), image); - // The full-page screenshot. AddImageToFailureDumpLocal(VisualVerificationMatchNames.FullScreenImageFileName, fullScreenImage); - - // The original element screenshot. - context.AddImageToFailureDump(originalElementScreenshotFileName, elementImageOriginal); - - // The original baseline image. + AddImageToFailureDumpLocal(originalElementScreenshotFileName, elementImageOriginal, dontWrap: true); AddImageToFailureDumpLocal(VisualVerificationMatchNames.BaselineImageFileName, baselineImageOriginal); - - // The cropped baseline image. AddImageToFailureDumpLocal(VisualVerificationMatchNames.CroppedBaselineImageFileName, baselineImageCropped); - - // The cropped element image. AddImageToFailureDumpLocal(VisualVerificationMatchNames.CroppedElementImageFileName, elementImageCropped); - - // The diff image. AddImageToFailureDumpLocal(VisualVerificationMatchNames.DiffImageFileName, diffImage); // The diff stats.