private static bool DocumentImagesAreEqual(FileInfo expectedOutputWordFile, FileInfo actualOutputWordFile) { var expectedOutputFileImageDirectory = SaveDocumentImages(expectedOutputWordFile); var actualOutputFileImageDirectory = SaveDocumentImages(actualOutputWordFile); //Return true if both directories are empty (it means that no images were saved from docx document). //in other case (if one folder contains images) compare them if (expectedOutputFileImageDirectory == null && actualOutputFileImageDirectory == null) { return(true); } return(ImageDocumentComparer.AllImageFilesInDirectoryAreEqual(expectedOutputFileImageDirectory, actualOutputFileImageDirectory)); }
/// <summary> /// Compare two pdf files using <see cref="ImageMagick"/>. First generate from pdf images after that compare all images in output directory /// </summary> /// <param name="expectedPdfFile"></param> /// <param name="actualPdfFile"></param> /// <returns></returns> public static bool ComparingFilesAsImageAreEqual(FileInfo expectedPdfFile, FileInfo actualPdfFile) { var expectedPdfImagesOutputDir = new DirectoryInfo(Path.Combine(expectedPdfFile.Directory.FullName, $"{expectedPdfFile.Name}_Images")); var actualPdfImagesOutputDir = new DirectoryInfo(Path.Combine(actualPdfFile.Directory.FullName, $"{actualPdfFile.Name}_Images")); if (!expectedPdfImagesOutputDir.Exists) { expectedPdfImagesOutputDir.Create(); } if (!actualPdfImagesOutputDir.Exists) { actualPdfImagesOutputDir.Create(); } GenerateImagesFromPdf(expectedPdfFile, expectedPdfImagesOutputDir); GenerateImagesFromPdf(actualPdfFile, actualPdfImagesOutputDir); return(ImageDocumentComparer.AllImageFilesInDirectoryAreEqual(expectedPdfImagesOutputDir, actualPdfImagesOutputDir)); }