Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/2792-excluding-parent-property-sho…
Browse files Browse the repository at this point in the history
…uldn't-exclude-children
  • Loading branch information
ewoutkramer authored Jul 24, 2024
2 parents d748cc7 + c150395 commit ac0c22b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Hl7.Fhir.Base/Model/Generated/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public Hl7.Fhir.Model.ResourceReference SecurityContext
/// </summary>
[FhirElement("content", Order=70)]
[NotMapped(Since=FhirRelease.R4)]
[Cardinality(Min=1,Max=1)]
[DataMember]
public Hl7.Fhir.Model.Base64Binary ContentElement
{
Expand Down
34 changes: 34 additions & 0 deletions src/Hl7.Fhir.Shared.Tests/Validation/ValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
*/

using FluentAssertions;
using Hl7.Fhir.Model;
using Hl7.Fhir.Validation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -232,5 +233,38 @@ public void TestXhtmlValidation()
validateErrorOrFail(p, true);
}
#endif

[TestMethod]
public void TestBinaryContentCardinalityValidation()
{
var bin = new Binary
{
ContentType = "text/plain",
Content = [0, 1, 2, 3],
Data = [0, 1, 2, 3]
};

var validation = () => DotNetAttributeValidation.Validate(bin);
validation.Should().NotThrow<ValidationException>();


//We removed the cardinality validation for the Content property for issue #2821
bin = new Binary
{
ContentType = "text/plain",
Data = [0, 1, 2, 3]
};

validation = () => DotNetAttributeValidation.Validate(bin);
validation.Should().NotThrow<ValidationException>();

bin = new Binary
{
Data = [0, 1, 2, 3]
};

validation = () => DotNetAttributeValidation.Validate(bin);
validation.Should().Throw<ValidationException>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ private static void areEqual(IElementDefinitionSummary left, IElementDefinitionS
left.IsModifier.Should().Be(right.IsModifier, context + ": IsModifier differs");
left.IsChoiceElement.Should().Be(right.IsChoiceElement, context + ": IsChoiceElement differs");
left.IsCollection.Should().Be(right.IsCollection, context + ": IsCollection differs");
left.IsRequired.Should().Be(right.IsRequired, context + ": IsRequired differs");

if (context != "Binary.content") //because of issue #2821
left.IsRequired.Should().Be(right.IsRequired, context + ": IsRequired differs");

left.IsResource.Should().Be(right.IsResource, context + ": IsResource differs");
// left.Order.Should().Be(right.Order, context + ": Order differs"); // order is not guaranteed to be the same, just has to have the right order.
left.Representation.Should().Be(right.Representation, context + ": Representation differs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ private static void areEqual(IElementDefinitionSummary left, IElementDefinitionS
left.IsModifier.Should().Be(right.IsModifier, context + ": IsModifier differs");
left.IsChoiceElement.Should().Be(right.IsChoiceElement, context + ": IsChoiceElement differs");
left.IsCollection.Should().Be(right.IsCollection, context + ": IsCollection differs");
left.IsRequired.Should().Be(right.IsRequired, context + ": IsRequired differs");

if (context != "Binary.content") //because of issue #2821
left.IsRequired.Should().Be(right.IsRequired, context + ": IsRequired differs");

left.IsResource.Should().Be(right.IsResource, context + ": IsResource differs");
// left.Order.Should().Be(right.Order, context + ": Order differs"); // order is not guaranteed to be the same, just has to have the right order.
left.Representation.Should().Be(right.Representation, context + ": Representation differs");
Expand Down

0 comments on commit ac0c22b

Please sign in to comment.