diff --git a/src/Hl7.Fhir.Support.Poco.Tests/Model/PocoDictionaryTests.cs b/src/Hl7.Fhir.Support.Poco.Tests/Model/PocoDictionaryTests.cs index fd68c6c8a..4a10efb4b 100644 --- a/src/Hl7.Fhir.Support.Poco.Tests/Model/PocoDictionaryTests.cs +++ b/src/Hl7.Fhir.Support.Poco.Tests/Model/PocoDictionaryTests.cs @@ -14,21 +14,18 @@ public void DynamicResourceAcceptsEverything() { var dr = new DynamicResource() { - ["name"] = "John", - ["age"] = 23, - ["alive"] = true, - ["dob"] = new Date(1972, 11, 30), + ["name"] = new FhirString("John"), #pragma warning disable CA2244 - ["weight"] = 75.5m, + ["weight"] = new FhirDecimal(75.5m), #pragma warning restore CA2244 - ["weight"] = 80.0m + ["weight"] = new FhirDecimal(80.0m), + ["someArray"] = new List { new("element") } }; - dr["name"].Should().Be("John"); - dr["age"].Should().Be(23); - dr["alive"].Should().Be(true); - dr["dob"].Should().BeOfType().Which.Value.Should().Be("1972-11-30"); - dr["weight"].Should().Be(80.0m); + dr["name"].Should().BeOfType().Which.Value.Should().Be("John"); + dr["weight"].Should().BeOfType().Which.Value.Should().Be(80.0m); + dr["someArray"].Should().BeAssignableTo>() + .Which.Count.Should().Be(1); dr["name"] = null!; dr.TryGetValue("name", out _).Should().BeFalse(); @@ -69,11 +66,11 @@ public void CanReadSpecialProperties() patient.AddExtension("http://nu.nl", new FhirBoolean(true)); - patient["active"].Should().BeOfType().And - .BeAssignableTo().Which["value"].Should().Be(true); + patient["active"].Should().BeOfType(). + Which.ObjectValue.Should().Be(true); patient["text"].Should().BeOfType().And - .BeAssignableTo().Which["div"].Should().BeOfType().And - .BeAssignableTo().Which["value"].Should().Be("
hello
"); + .BeAssignableTo().Which["div"].Should().BeOfType() + .Which.ObjectValue.Should().Be("
hello
"); patient["meta"].Should().BeOfType().And .BeAssignableTo().Which["id"].Should().Be("4"); var extension = patient["extension"].Should().BeOfType>().Which.Should().ContainSingle().Subject; diff --git a/src/Hl7.Fhir.Support.Poco.Tests/NewPocoSerializers/FhirJsonSerializationTests.cs b/src/Hl7.Fhir.Support.Poco.Tests/NewPocoSerializers/FhirJsonSerializationTests.cs index 3ce303460..192c49e5f 100644 --- a/src/Hl7.Fhir.Support.Poco.Tests/NewPocoSerializers/FhirJsonSerializationTests.cs +++ b/src/Hl7.Fhir.Support.Poco.Tests/NewPocoSerializers/FhirJsonSerializationTests.cs @@ -73,11 +73,14 @@ public void SerializesInvalidData() { var options = new JsonSerializerOptions().ForFhir(typeof(Patient).Assembly); - FhirBoolean b = new() { ObjectValue = "treu" }; - var jdoc = JsonDocument.Parse(JsonSerializer.Serialize(b, options)); - Assert.AreEqual("treu", jdoc.RootElement.GetProperty("value").GetString()); + var b = new FhirBoolean() { ObjectValue = "treu" }; + var pInvalid = new Patient { ActiveElement = b }; - Patient p = new() { Contact = new() { new Patient.ContactComponent() } }; + var jdoc = JsonDocument.Parse(JsonSerializer.Serialize(pInvalid, options)); + Assert.AreEqual("treu", jdoc.RootElement + .GetProperty("active").GetString()); + + Patient p = new() { Contact = [new Patient.ContactComponent()] }; jdoc = JsonDocument.Parse(JsonSerializer.Serialize(p, options)); var contactArray = jdoc.RootElement.GetProperty("contact"); contactArray.GetArrayLength().Should().Be(1);