public virtual void ShouldAdaptCorrectly() { TSImpl ts = new TSImpl(new PlatformDate()); BareANY adapted = this.adapter.Adapt(StandardDataType.IVL_FULL_DATE.Type, ts); Assert.AreEqual(((IVL <TS, Interval <PlatformDate> >)adapted).Value.Low, ts.Value, "low"); }
public virtual void ShouldProduceResultWithNoErrorsWhenNullFlavorSupplied() { // writing test based on RM16399 ModelToXmlResult result = new ModelToXmlResult(); TS ts = new TSImpl(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.ASKED_BUT_UNKNOWN); FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, false, SpecificationVersion.R02_04_02 , null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.IsTrue(result.IsValid()); Assert.AreEqual("<tsValue nullFlavor=\"ASKU\"/>", xmlOutput.Trim()); }
private BareANY ConvertDataType(BareANY dataType) { object bareValue = dataType.BareValue; MbDate mbDate = (bareValue is MbDate ? (MbDate)bareValue : null); PlatformDate date = (mbDate == null ? null : mbDate.Value); ANYImpl <PlatformDate> result = new TSImpl(); result.DataType = dataType.DataType; result.NullFlavor = dataType.NullFlavor; result.BareValue = date; result.Operator = ((ANYMetaData)dataType).Operator; return(result); }
public virtual void ShouldProduceResultWithFullDateSpecializationType() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23); TS ts = new TSImpl(date); ts.DataType = StandardDataType.TS_FULLDATE; FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.IsTrue(result.GetHl7Errors().IsEmpty(), "no errors"); Assert.AreEqual("<tsValue specializationType=\"TS.FULLDATE\" value=\"19990423\" xsi:type=\"TS\"/>", xmlOutput.Trim(), "output as expected" ); }
public virtual void ShouldProduceResultWithMissingSpecializationTypeError() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23, 1, 2, 3, 0); TS ts = new TSImpl(date); FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); Assert.AreEqual(1, result.GetHl7Errors().Count, "1 error"); Assert.AreEqual("No specializationType provided. Value should be one of TS.FULLDATE / TS.FULLDATETIME / TS.FULLDATEPARTTIME. TS.FULLDATETIME will be assumed." , result.GetHl7Errors()[0].GetMessage()); // avoid having to assess the timezone Assert.IsTrue(xmlOutput.Trim().StartsWith("<tsValue specializationType=\"TS.FULLDATETIME\" value=\"19990423010203.0000")); Assert.IsTrue(xmlOutput.Trim().EndsWith("\" xsi:type=\"TS\"/>")); }
public virtual void ShouldProduceResultWithFullDateTimeSpecializationType() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(1999, 3, 23, 1, 2, 3, 0); TS ts = new TSImpl(date); ts.DataType = StandardDataType.TS_FULLDATETIME; FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, null, "tsValue" , "TS.FULLDATEWITHTIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); string xmlOutput = this.formatter.Format(context, ts); // avoid having to assess the timezone Assert.IsTrue(result.GetHl7Errors().IsEmpty(), "no errors"); Assert.IsTrue(xmlOutput.Trim().StartsWith("<tsValue specializationType=\"TS.FULLDATETIME\" value=\"19990423010203.0000")); Assert.IsTrue(xmlOutput.Trim().EndsWith("\" xsi:type=\"TS\"/>")); }