Skip to content

Commit

Permalink
Added better docs + test on ParseBindable for CodeableReference.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoutkramer committed Feb 14, 2024
1 parent 640c2dc commit 38b05bc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 54 deletions.
2 changes: 2 additions & 0 deletions src/Hl7.Fhir.Base/ElementModel/TypedElementParseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public static class TypedElementParseExtensions
/// 'Extension' => depends on value[x]
/// 'string' => code
/// 'uri' => code
/// 'CodeableReference' => CodeableConcept if 'concept' is present, otherwise null
/// </remarks>
public static Element? ParseBindable(this ITypedElement instance)
#pragma warning disable CS0618 // Type or member is obsolete
=> instance.ParseBindableInternal();
#pragma warning restore CS0618 // Type or member is obsolete

/// <inheritdoc cref="ParseBindable"/>
[Obsolete("WARNING! Intended for internal API usage exclusively, interface IBaseElementNavigator can be changed in " +
"the near future.")]
public static Element? ParseBindableInternal<T>(this IBaseElementNavigator<T> instance) where T : IBaseElementNavigator<T>
Expand Down
26 changes: 0 additions & 26 deletions src/Hl7.Fhir.ElementModel.R4B.Tests/ParseExtensionsTests.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Hl7.Fhir.ElementModel.R5.Tests/ParseExtensionsTests.cs

This file was deleted.

27 changes: 25 additions & 2 deletions src/Hl7.Fhir.ElementModel.Shared.Tests/ParseExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Hl7.Fhir.ElementModel;
using FluentAssertions;
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Terminology;
using System.Collections.Generic;
using Xunit;

namespace Hl7.Fhir.Validation
{
public partial class ParseExtensionsTests
public class ParseExtensionsTests
{
[Fact]
public void TestParseQuantity()
Expand Down Expand Up @@ -131,5 +134,25 @@ public void TestParseUnbindable()
var xe = node.ParseBindable();
Assert.Null(xe);
}

[Fact]
public void TestParseCodeableReference()
{
var i = new CodeableReference
{
Reference = new ResourceReference("http://example.org/fhir/Patient/1"),
Concept = new CodeableConcept("http://nu.nl", "bla")
};

var node = i.ToTypedElement();
var p = node.ParseBindable();

p.Should().BeEquivalentTo(new { Coding = new List<Coding> { new Coding("http://nu.nl", "bla") } });

i.Concept = null;
node = i.ToTypedElement();
p = node.ParseBindable();
p.Should().BeNull();
}
}
}

0 comments on commit 38b05bc

Please sign in to comment.