diff --git a/src/Thumbnails/RevitTumbnailExtractor.cs b/src/Thumbnails/RevitTumbnailExtractor.cs index b4e4078..d6a65c8 100644 --- a/src/Thumbnails/RevitTumbnailExtractor.cs +++ b/src/Thumbnails/RevitTumbnailExtractor.cs @@ -84,13 +84,11 @@ private static int GetPngOffset(byte[] thumbnailBytes) { return startingOffset; } - if (markerFound && (previousValue == RevitFileMap.PngImageMarker.MARKER_13)) { previousValue = pointer; continue; } - markerFound = false; break; @@ -100,7 +98,6 @@ private static int GetPngOffset(byte[] thumbnailBytes) previousValue = pointer; continue; } - markerFound = false; break; @@ -110,7 +107,6 @@ private static int GetPngOffset(byte[] thumbnailBytes) previousValue = pointer; continue; } - markerFound = false; break; @@ -120,7 +116,6 @@ private static int GetPngOffset(byte[] thumbnailBytes) previousValue = pointer; continue; } - markerFound = false; break; @@ -130,7 +125,6 @@ private static int GetPngOffset(byte[] thumbnailBytes) previousValue = pointer; continue; } - markerFound = false; break; @@ -140,7 +134,6 @@ private static int GetPngOffset(byte[] thumbnailBytes) previousValue = pointer; continue; } - markerFound = false; break; } diff --git a/tests/Resources/Thumbnails/Valid/7-PS-66_R3.png b/tests/Resources/Thumbnails/Valid/7-PS-66_R3.png index ff7b91e..65db431 100644 Binary files a/tests/Resources/Thumbnails/Valid/7-PS-66_R3.png and b/tests/Resources/Thumbnails/Valid/7-PS-66_R3.png differ diff --git a/tests/Resources/Thumbnails/Valid/A1ANG-3.png b/tests/Resources/Thumbnails/Valid/A1ANG-3.png index cbb4894..d22abc9 100644 Binary files a/tests/Resources/Thumbnails/Valid/A1ANG-3.png and b/tests/Resources/Thumbnails/Valid/A1ANG-3.png differ diff --git a/tests/Resources/Thumbnails/Valid/U0000850_7-PS-66.png b/tests/Resources/Thumbnails/Valid/U0000850_7-PS-66.png index 4e0579c..925aa38 100644 Binary files a/tests/Resources/Thumbnails/Valid/U0000850_7-PS-66.png and b/tests/Resources/Thumbnails/Valid/U0000850_7-PS-66.png differ diff --git a/tests/Resources/Thumbnails/Valid/qf_hatco_hdw-2bn_cat.png b/tests/Resources/Thumbnails/Valid/qf_hatco_hdw-2bn_cat.png index da5a739..7acdab6 100644 Binary files a/tests/Resources/Thumbnails/Valid/qf_hatco_hdw-2bn_cat.png and b/tests/Resources/Thumbnails/Valid/qf_hatco_hdw-2bn_cat.png differ diff --git a/tests/ThumbnailFixture.cs b/tests/ThumbnailFixture.cs index b604019..1a5d395 100644 --- a/tests/ThumbnailFixture.cs +++ b/tests/ThumbnailFixture.cs @@ -33,15 +33,16 @@ public void DwgThumbnailIsGenerated(string dwgRelativePath) // Setup dwgRelativePath = dwgRelativePath?.Replace('/', Path.DirectorySeparatorChar); var dwgFilePath = Directory.GetFiles(PathToValidFiles, "*.dwg").FirstOrDefault(f => f.EndsWith(dwgRelativePath)); - var dwgThumbnailPath = Path.ChangeExtension(Path.Combine(Environment.CurrentDirectory, Path.GetFileName(dwgFilePath)), "png"); + var dwgThumbnailPath = Path.ChangeExtension(dwgFilePath, "png"); // Act var dwgThumbnailer = new DwgThumbnailExtractor(); - var fileExtracted = dwgThumbnailer.TryExtractFile(dwgFilePath, dwgThumbnailPath); + var thumbDwgBytes = dwgThumbnailer.ExtractThumbnailBytes(dwgFilePath); + var thumbPngBytes = File.ReadAllBytes(dwgThumbnailPath); // Assert - Assert.True(fileExtracted); - Assert.True(File.Exists(dwgThumbnailPath)); + Assert.NotEmpty(thumbDwgBytes); + Assert.Equal(thumbPngBytes, thumbDwgBytes); } /// The thumbnails are generated for RFAs. @@ -53,15 +54,16 @@ public void RfaThumbnailIsGenerated(string rfaRelativePath) // Setup rfaRelativePath = rfaRelativePath?.Replace('/', Path.DirectorySeparatorChar); var rfaFilePath = Directory.GetFiles(PathToValidFiles, "*.rfa").FirstOrDefault(f => f.EndsWith(rfaRelativePath)); - var rfaThumbnailPath = Path.ChangeExtension(Path.Combine(Environment.CurrentDirectory, Path.GetFileName(rfaFilePath)), "png"); + var rfaThumbnailPath = Path.ChangeExtension(rfaFilePath, "png"); // Act var rfaThumbnailer = new RevitTumbnailExtractor(); - var fileExtracted = rfaThumbnailer.TryExtractFile(rfaFilePath, rfaThumbnailPath); + var thumbRfaBytes = rfaThumbnailer.ExtractThumbnailBytes(rfaFilePath); + var thumbPngBytes = File.ReadAllBytes(rfaThumbnailPath); // Assert - Assert.True(fileExtracted); - Assert.True(File.Exists(rfaThumbnailPath)); + Assert.NotEmpty(thumbRfaBytes); + Assert.Equal(thumbPngBytes, thumbRfaBytes); } } }