Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
salaros committed Oct 18, 2023
1 parent 42d7236 commit 8b52bfd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/Thumbnails/RevitTumbnailExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -100,7 +98,6 @@ private static int GetPngOffset(byte[] thumbnailBytes)
previousValue = pointer;
continue;
}

markerFound = false;
break;

Expand All @@ -110,7 +107,6 @@ private static int GetPngOffset(byte[] thumbnailBytes)
previousValue = pointer;
continue;
}

markerFound = false;
break;

Expand All @@ -120,7 +116,6 @@ private static int GetPngOffset(byte[] thumbnailBytes)
previousValue = pointer;
continue;
}

markerFound = false;
break;

Expand All @@ -130,7 +125,6 @@ private static int GetPngOffset(byte[] thumbnailBytes)
previousValue = pointer;
continue;
}

markerFound = false;
break;

Expand All @@ -140,7 +134,6 @@ private static int GetPngOffset(byte[] thumbnailBytes)
previousValue = pointer;
continue;
}

markerFound = false;
break;
}
Expand Down
Binary file modified tests/Resources/Thumbnails/Valid/7-PS-66_R3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Resources/Thumbnails/Valid/A1ANG-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Resources/Thumbnails/Valid/U0000850_7-PS-66.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Resources/Thumbnails/Valid/qf_hatco_hdw-2bn_cat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions tests/ThumbnailFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>The thumbnails are generated for RFAs.</summary>
Expand All @@ -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);
}
}
}

0 comments on commit 8b52bfd

Please sign in to comment.