public void TestIsNullOrEmpty_Extension() { var e = new Extension(); Assert.IsTrue(e.IsNullOrEmpty()); var value = new FhirString("test"); Assert.IsFalse(value.IsNullOrEmpty()); e.Value = value; Assert.IsFalse(e.IsNullOrEmpty()); e.Value = null; Assert.IsTrue(e.IsNullOrEmpty()); }
public void TestIsNullOrEmpty_Coding() { var coding = new Coding(); Assert.IsTrue(coding.IsNullOrEmpty()); var uri = new FhirUri(); Assert.IsTrue(uri.IsNullOrEmpty()); coding.SystemElement = uri; Assert.IsTrue(coding.IsNullOrEmpty()); uri.Value = "http://example.org/"; Assert.IsFalse(uri.IsNullOrEmpty()); Assert.IsFalse(coding.IsNullOrEmpty()); Assert.IsFalse((coding as Base).IsNullOrEmpty()); uri.Value = null; Assert.IsTrue(uri.IsNullOrEmpty()); Assert.IsTrue(coding.IsNullOrEmpty()); var extension = new Extension(); Assert.IsTrue(extension.IsNullOrEmpty()); coding.Extension.Add(extension); Assert.IsTrue(coding.IsNullOrEmpty()); var extensionValue = new Coding(null, "test"); Assert.IsFalse(extensionValue.IsNullOrEmpty()); extension.Value = extensionValue; Assert.IsFalse(extension.IsNullOrEmpty()); Assert.IsFalse(coding.IsNullOrEmpty()); Assert.IsFalse((coding as Base).IsNullOrEmpty()); extensionValue.Code = null; Assert.IsTrue(extensionValue.IsNullOrEmpty()); Assert.IsTrue(extension.IsNullOrEmpty()); Assert.IsTrue(coding.IsNullOrEmpty()); coding.Extension.Clear(); Assert.IsTrue(coding.IsNullOrEmpty()); }
void testIsNullOrEmpty_StringPrimitive <T>(string exampleValue = "test") where T : Primitive <string>, IStringValue, new() { var elem = new T(); Assert.IsTrue(elem.IsNullOrEmpty()); elem.Value = string.Empty; Assert.IsTrue(elem.IsNullOrEmpty()); Assert.IsTrue((elem as Base).IsNullOrEmpty()); Assert.IsFalse(string.IsNullOrEmpty(exampleValue)); elem.Value = exampleValue; Assert.IsFalse(elem.IsNullOrEmpty()); Assert.IsFalse((elem as Base).IsNullOrEmpty()); elem.Value = null; Assert.IsTrue(elem.IsNullOrEmpty()); Assert.IsTrue((elem as Base).IsNullOrEmpty()); var extension = new Extension(); Assert.IsTrue(extension.IsNullOrEmpty()); elem.Extension.Add(extension); Assert.IsTrue(elem.IsNullOrEmpty()); var extensionValue = new FhirString(exampleValue); Assert.IsFalse(extensionValue.IsNullOrEmpty()); extension.Value = extensionValue; Assert.IsFalse(extension.IsNullOrEmpty()); Assert.IsFalse(elem.IsNullOrEmpty()); Assert.IsFalse((elem as Base).IsNullOrEmpty()); extensionValue.Value = null; Assert.IsTrue(extensionValue.IsNullOrEmpty()); Assert.IsTrue(extension.IsNullOrEmpty()); Assert.IsTrue(elem.IsNullOrEmpty()); elem.Extension.Clear(); Assert.IsTrue(elem.IsNullOrEmpty()); }
void testIsNullOrEmpty_Primitive <T, V>(V testValue, V emptyValue) where T : Primitive <V>, IValue <V>, new() { var elem = new T(); Assert.IsTrue(elem.IsNullOrEmpty()); elem.Value = emptyValue; Assert.IsFalse(elem.IsNullOrEmpty()); Assert.IsFalse((elem as Base).IsNullOrEmpty()); elem.Value = testValue; Assert.IsFalse(elem.IsNullOrEmpty()); Assert.IsFalse((elem as Base).IsNullOrEmpty()); elem.Value = default(V); Assert.IsTrue(elem.IsNullOrEmpty()); Assert.IsTrue((elem as Base).IsNullOrEmpty()); var extension = new Extension(); Assert.IsTrue(extension.IsNullOrEmpty()); elem.Extension.Add(extension); Assert.IsTrue(elem.IsNullOrEmpty()); var extensionValue = new FhirString("test"); Assert.IsFalse(extensionValue.IsNullOrEmpty()); extension.Value = extensionValue; Assert.IsFalse(extension.IsNullOrEmpty()); Assert.IsFalse(elem.IsNullOrEmpty()); Assert.IsFalse((elem as Base).IsNullOrEmpty()); extensionValue.Value = null; Assert.IsTrue(extensionValue.IsNullOrEmpty()); Assert.IsTrue(extension.IsNullOrEmpty()); Assert.IsTrue(elem.IsNullOrEmpty()); elem.Extension.Clear(); Assert.IsTrue(elem.IsNullOrEmpty()); }