From 9eaeecfae9769094a6636861f064ee9f2932c6f6 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 22 Apr 2020 12:17:33 +0200 Subject: [PATCH] Add tests for setting iptc value with strict option disabled --- .../Metadata/Profiles/IPTC/IptcProfile.cs | 2 +- .../Profiles/IPTC/IptcProfileTests.cs | 36 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 9206e43771..f138cc650f 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc public IptcProfile DeepClone() => new IptcProfile(this); /// - /// Returns all value with the specified tag. + /// Returns all values with the specified tag. /// /// The tag of the iptc value. /// The values found with the specified tag. diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index d9f44cef9c..3baea45d62 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -25,8 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC } [Theory] - [MemberData("AllIptcTags")] - public void IptcProfile_SetValue_WithStrictOption_Works(IptcTag tag) + [MemberData(nameof(AllIptcTags))] + public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag) { // arrange var profile = new IptcProfile(); @@ -41,6 +41,23 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC 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] [InlineData(IptcTag.DigitalCreationDate)] [InlineData(IptcTag.ExpirationDate)] @@ -199,13 +216,6 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } - [Fact] - public void IptcProfile_SetNewValue_RespectsMaxLength() - { - // arrange - var profile = new IptcProfile(); - } - [Theory] [InlineData(IptcTag.ObjectAttribute)] [InlineData(IptcTag.SubjectReference)] @@ -292,7 +302,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC [Fact] public void IptcProfile_RemoveByTag_RemovesAllEntrys() { - // arange + // arrange var profile = new IptcProfile(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -308,7 +318,7 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC [Fact] public void IptcProfile_RemoveByTagAndValue_Works() { - // arange + // arrange var profile = new IptcProfile(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -322,9 +332,9 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.IPTC } [Fact] - public void IptcProfile_GetValue_RetrievesAllEntrys() + public void IptcProfile_GetValue_RetrievesAllEntries() { - // arange + // arrange var profile = new IptcProfile(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2");