Browse Source

Fix for setting image height and width metadata (#857)

This was raised by SonarQube; it detected identical expressions on both sides of the operator.
pull/860/head
Paul Astbury-Thomas 4 years ago
committed by GitHub
parent
commit
32cf9dc1bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs
  2. 11
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/FileTagAssetMetadataSourceTests.cs

2
backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs

@ -77,7 +77,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
var pw = file.Properties.PhotoWidth; var pw = file.Properties.PhotoWidth;
var ph = file.Properties.PhotoHeight; var ph = file.Properties.PhotoHeight;
if (pw > 0 && pw > 0) if (pw > 0 && ph > 0)
{ {
command.Metadata.SetPixelWidth(pw); command.Metadata.SetPixelWidth(pw);
command.Metadata.SetPixelHeight(ph); command.Metadata.SetPixelHeight(ph);

11
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/FileTagAssetMetadataSourceTests.cs

@ -40,6 +40,17 @@ namespace Squidex.Domain.Apps.Entities.Assets
Assert.Equal(170, command.Metadata.GetPixelHeight()); Assert.Equal(170, command.Metadata.GetPixelHeight());
} }
[Fact]
public async Task Should_not_set_image_height_and_width_metadata_when_file_does_not_have_those_values()
{
var command = Command("SampleAudio_0.4mb.mp3");
await sut.EnhanceAsync(command);
Assert.Null(command.Metadata.GetPixelWidth());
Assert.Null(command.Metadata.GetPixelHeight());
}
[Fact] [Fact]
public async Task Should_provide_metadata_for_audio() public async Task Should_provide_metadata_for_audio()
{ {

Loading…
Cancel
Save