public virtual void ShouldAdaptSetCorrectly() { IIImpl ii = new IIImpl(new Identifier("1", "2")); SET <IIImpl, Identifier> set = new SETImpl <IIImpl, Identifier>(typeof(IIImpl)); set.Value.Add(ii); BareANY adapted = this.adapter.Adapt("II", set); Assert.IsTrue(adapted is II); Assert.IsTrue(adapted == ii); }
public virtual void ShouldAdaptSetCorrectly() { SET <ST, string> list = new SETImpl <ST, string>(typeof(STImpl)); list.RawSet().Add("text1"); list.RawSet().Add("text2"); BareANY adapted = this.adapter.Adapt("SET<TN>", list); Assert.IsTrue(adapted is SET <TNImpl, TrivialName>, "type"); LinkedSet <TNImpl> set = (LinkedSet <TNImpl>)adapted.BareValue; Assert.AreEqual(2, set.Count, "size"); Assert.IsTrue(EveryItemTN(set), "all TNs"); Assert.IsTrue(HasItemWithValue(set, "text1")); Assert.IsTrue(HasItemWithValue(set, "text2")); }
public virtual void TestFormatValueNonNull() { PlatformDate calendar1 = DateUtil.GetDate(1999, 0, 1, 12, 29, 59, 0); PlatformDate calendar2 = DateUtil.GetDate(2001, 1, 3, 13, 30, 00, 0); SETImpl <TS, PlatformDate> set = new SETImpl <TS, PlatformDate>(typeof(TSImpl)); set.RawSet().AddAll(MakeSet(calendar1, calendar2)); string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "blah", "SET<TS>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality. Create("1-4"), false), set); string currentTimeZone1 = DateFormatUtil.Format(calendar1, "Z"); string currentTimeZone2 = DateFormatUtil.Format(calendar2, "Z"); string expectedValue1 = "19990101122959.0000" + currentTimeZone1; string expectedValue2 = "20010203133000.0000" + currentTimeZone2; AssertXml("non null", "<blah value=\"" + expectedValue1 + "\"/><blah value=\"" + expectedValue2 + "\"/>", result); }
public virtual BareANY Adapt(string toDataTypeName, BareANY any) { MethodInfo rawCollectionMethod = any.GetType().GetMethod("RawCollection"); ICollection <object> collection = (ICollection <object>)rawCollectionMethod.Invoke(any, new object[] { }); SETImpl <TNImpl, TrivialName> adaptedSet = new SETImpl <TNImpl, TrivialName>(typeof(TNImpl)); if (any.HasNullFlavor()) { NullFlavor nullFlavor = any.NullFlavor; adaptedSet.NullFlavor = nullFlavor; } else { adaptedSet.RawSet().AddAll(ToSetOfTrivialName(collection)); } return(adaptedSet); }
public virtual void TestFormatValueNonNull() { string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "blah", "SET<CE>", "x_BasicUnitsOfMeasure", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY , Cardinality.Create("1-4"), false, SpecificationVersion.R02_04_02, null, null, CodingStrength.CNE, null, false), SETImpl <ANY <object>, object> .Create <CE, Code>(typeof(CEImpl), MakeSet(Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CENTIMETRE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.KILOGRAM))); Assert.IsTrue(this.result.IsValid()); AssertXml("non null", "<blah code=\"cm\" codeSystem=\"2.16.840.1.113883.5.141\"/><blah code=\"kg\" codeSystem=\"2.16.840.1.113883.5.141\"/>" , result); }
public virtual void TestFormatValueEmptySet() { string result = this.formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(this.result , null, "blah", "SET<CD>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, false, SpecificationVersion.R02_04_02 , null, null, CodingStrength.CNE, false), SETImpl <ANY <object>, object> .Create <CD, Code>(typeof(CDImpl), new HashSet <Code >())); Assert.IsTrue(this.result.IsValid()); AssertXml("non null", "<blah nullFlavor=\"NI\"/>", result); }
public virtual void TestFormatValueTooFew() { string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "blah", "SET<ST>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("4-6" ), false), SETImpl <ANY <object>, object> .Create <ST, string>(typeof(STImpl), MakeSet("Fred", "Wilma", "Barney"))); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); Assert.AreEqual("Number of elements (3) is less than the specified minimum (4)", this.result.GetHl7Errors()[0].GetMessage ()); Assert.IsTrue(result.Contains("<blah>Fred</blah>")); Assert.IsTrue(result.Contains("<blah>Wilma</blah>")); Assert.IsTrue(result.Contains("<blah>Barney</blah>")); }
public virtual void TestFormatValueNonNull() { string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "blah", "SET<ST>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality. Create("1-4"), false), SETImpl <ANY <object>, object> .Create <ST, string>(typeof(STImpl), MakeSet("Fred", "Wilma"))); AssertXml("non null", "<blah>Fred</blah><blah>Wilma</blah>", result); }
public virtual void TestFormatValueNonNull() { string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "blah", "SET<TEL.PHONEMAIL>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality .Create("1-4"), false, SpecificationVersion.R02_04_03, null, null, null, false), SETImpl <ANY <object>, object> .Create <TEL , TelecommunicationAddress>(typeof(TELImpl), MakeTelecommunicationAddressSet("Fred"))); AssertXml("non null", "<blah specializationType=\"TEL.PHONE\" value=\"mailto:Fred\" xsi:type=\"TEL\"/>", result); }
public virtual void TestFormatValueNonNull() { PhysicalQuantity numerator1 = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CENTIMETRE); PhysicalQuantity denominator1 = new PhysicalQuantity(new BigDecimal(2), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CUBIC_CENTIMETER); PhysicalQuantity numerator2 = new PhysicalQuantity(BigDecimal.TEN, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .MILLIMETER); PhysicalQuantity denominator2 = new PhysicalQuantity(new BigDecimal(11), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CUBIC_MILIMETER); Ratio <PhysicalQuantity, PhysicalQuantity> ratio1 = new Ratio <PhysicalQuantity, PhysicalQuantity>(numerator1, denominator1 ); Ratio <PhysicalQuantity, PhysicalQuantity> ratio2 = new Ratio <PhysicalQuantity, PhysicalQuantity>(numerator2, denominator2 ); SETImpl <RTO <PhysicalQuantity, PhysicalQuantity>, Ratio <PhysicalQuantity, PhysicalQuantity> > set = new SETImpl <RTO <PhysicalQuantity , PhysicalQuantity>, Ratio <PhysicalQuantity, PhysicalQuantity> >(typeof(RTOImpl <PhysicalQuantity, PhysicalQuantity>)); set.RawSet().AddAll(MakeSet(ratio1, ratio2)); string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "blah", "SET<RTO<PQ.DRUG,PQ.TIME>>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY , Cardinality.Create("1-4"), false, SpecificationVersion.R02_04_02, null, null, null, false), set); AssertXml("non null", "<blah><numerator unit=\"cm\" value=\"1\"/><denominator unit=\"cm3\" value=\"2\"/></blah><blah><numerator unit=\"mm\" value=\"10\"/><denominator unit=\"mm3\" value=\"11\"/></blah>" , result); }