Browse Source

Add tests for setting iptc value with strict option disabled

pull/1184/head
Brian Popow 6 years ago
parent
commit
9eaeecfae9
  1. 2
      src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs
  2. 36
      tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs

2
src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs

@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc
public IptcProfile DeepClone() => new IptcProfile(this); public IptcProfile DeepClone() => new IptcProfile(this);
/// <summary> /// <summary>
/// Returns all value with the specified tag. /// Returns all values with the specified tag.
/// </summary> /// </summary>
/// <param name="tag">The tag of the iptc value.</param> /// <param name="tag">The tag of the iptc value.</param>
/// <returns>The values found with the specified tag.</returns> /// <returns>The values found with the specified tag.</returns>

36
tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs

@ -25,8 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
} }
[Theory] [Theory]
[MemberData("AllIptcTags")] [MemberData(nameof(AllIptcTags))]
public void IptcProfile_SetValue_WithStrictOption_Works(IptcTag tag) public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag)
{ {
// arrange // arrange
var profile = new IptcProfile(); var profile = new IptcProfile();
@ -41,6 +41,23 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
Assert.Equal(expectedLength, actual.Value.Length); Assert.Equal(expectedLength, actual.Value.Length);
} }
[Theory]
[MemberData(nameof(AllIptcTags))]
public void IptcProfile_SetValue_WithStrictDisabled_Works(IptcTag tag)
{
// arrange
var profile = new IptcProfile();
var value = new string('s', tag.MaxLength() + 1);
var expectedLength = value.Length;
// act
profile.SetValue(tag, value, false);
// assert
IptcValue actual = profile.GetValues(tag).First();
Assert.Equal(expectedLength, actual.Value.Length);
}
[Theory] [Theory]
[InlineData(IptcTag.DigitalCreationDate)] [InlineData(IptcTag.DigitalCreationDate)]
[InlineData(IptcTag.ExpirationDate)] [InlineData(IptcTag.ExpirationDate)]
@ -199,13 +216,6 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption);
} }
[Fact]
public void IptcProfile_SetNewValue_RespectsMaxLength()
{
// arrange
var profile = new IptcProfile();
}
[Theory] [Theory]
[InlineData(IptcTag.ObjectAttribute)] [InlineData(IptcTag.ObjectAttribute)]
[InlineData(IptcTag.SubjectReference)] [InlineData(IptcTag.SubjectReference)]
@ -292,7 +302,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
[Fact] [Fact]
public void IptcProfile_RemoveByTag_RemovesAllEntrys() public void IptcProfile_RemoveByTag_RemovesAllEntrys()
{ {
// arange // arrange
var profile = new IptcProfile(); var profile = new IptcProfile();
profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test");
profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Byline, "test2");
@ -308,7 +318,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
[Fact] [Fact]
public void IptcProfile_RemoveByTagAndValue_Works() public void IptcProfile_RemoveByTagAndValue_Works()
{ {
// arange // arrange
var profile = new IptcProfile(); var profile = new IptcProfile();
profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test");
profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Byline, "test2");
@ -322,9 +332,9 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC
} }
[Fact] [Fact]
public void IptcProfile_GetValue_RetrievesAllEntrys() public void IptcProfile_GetValue_RetrievesAllEntries()
{ {
// arange // arrange
var profile = new IptcProfile(); var profile = new IptcProfile();
profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test");
profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Byline, "test2");

Loading…
Cancel
Save