-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes invalid millisecond calculations for SubSecOriginal tag where
value is not in Canon's format.
- Loading branch information
Showing
5 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using CameraUtility.CameraFiles; | ||
using CameraUtility.Exif; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CameraUtility.Tests.CameraFiles | ||
{ | ||
public sealed class ImageFileTests | ||
{ | ||
[Theory] | ||
[InlineData("42", 420)] | ||
[InlineData("042", 42)] | ||
[InlineData("042000", 42)] | ||
public void SubSecondsOriginal_tag_gets_converted_to_milliseconds( | ||
string subSecondsTagValue, | ||
int expectedMilliseconds) | ||
{ | ||
var exifTags = new[] | ||
{ | ||
new Tag | ||
{ | ||
Type = 0x9003, | ||
Value = "2021:04:05 10:56:13" | ||
}, | ||
new Tag | ||
{ | ||
Type = 0x9291, | ||
Value = subSecondsTagValue | ||
} | ||
}; | ||
|
||
var sut = ImageFile.Create(new CameraFilePath("file.jpg"), exifTags).Value; | ||
|
||
var expected = new DateTime(2021, 04, 05, 10, 56, 13).AddMilliseconds(expectedMilliseconds); | ||
sut.Created.Should().Be(expected); | ||
} | ||
|
||
private sealed class Tag : | ||
ITag | ||
{ | ||
public int Type { get; internal init; } | ||
public string Directory => string.Empty; | ||
public string Value { get; internal init; } | ||
} | ||
|
||
private sealed record TestTag(string Value) : | ||
ITag | ||
{ | ||
public int Type => 0x9003; | ||
public string Directory => string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters