Skip to content

Commit

Permalink
Dry repetitive code even more! Makes comments superfluous
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Friedrich committed Jan 9, 2023
1 parent fb386fc commit f642da2
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit f642da2

Please sign in to comment.