Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master' into experiments-no-packed-color

pull/179/head
James Jackson-South 9 years ago
parent
commit
960c5fd8f0
  1. 7
      ImageSharp.sln
  2. 10
      src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
  3. 35
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifReaderTests.cs

7
ImageSharp.sln

@ -1,18 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.travis.yml = .travis.yml
appveyor.yml = appveyor.yml
codecov.yml = codecov.yml
CodeCoverage.runsettings = CodeCoverage.runsettings
contributing.md = contributing.md
dotnet-latest.ps1 = dotnet-latest.ps1
.github\CONTRIBUTING.md = .github\CONTRIBUTING.md
features.md = features.md
global.json = global.json
ImageSharp.ruleset = ImageSharp.ruleset
ImageSharp.sln.DotSettings = ImageSharp.sln.DotSettings
NuGet.config = NuGet.config

10
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs

@ -73,6 +73,8 @@ namespace ImageSharp
/// </returns>
public Collection<ExifValue> Read(byte[] data)
{
DebugGuard.NotNull(data, nameof(data));
Collection<ExifValue> result = new Collection<ExifValue>();
this.exifData = data;
@ -390,7 +392,13 @@ namespace ImageSharp
private string GetString(uint length)
{
return ToString(this.GetBytes(length));
byte[] data = this.GetBytes(length);
if (data == null || data.Length == 0)
{
return null;
}
return ToString(data);
}
private void GetThumbnail(uint offset)

35
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifReaderTests.cs

@ -0,0 +1,35 @@
// <copyright file="ExifReaderTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Tests
{
using System.Collections.ObjectModel;
using Xunit;
public class ExifReaderTests
{
[Fact]
public void Read_DataIsEmpty_ReturnsEmptyCollection()
{
ExifReader reader = new ExifReader();
byte[] data = new byte[] { };
Collection<ExifValue> result = reader.Read(data);
Assert.Equal(0, result.Count);
}
[Fact]
public void Read_DataIsMinimal_ReturnsEmptyCollection()
{
ExifReader reader = new ExifReader();
byte[] data = new byte[] { 69, 120, 105, 102, 0, 0 };
Collection<ExifValue> result = reader.Read(data);
Assert.Equal(0, result.Count);
}
}
}
Loading…
Cancel
Save