public virtual void TestGetAttributeNameValuePairsNullValue() { IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null , null, false), null, new TSImpl()); // a null value for TS elements results in a nullFlavor attribute Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("nullFlavor"), "key as expected"); Assert.AreEqual(AbstractPropertyFormatter.NULL_FLAVOR_NO_INFORMATION, result.SafeGet("nullFlavor"), "value as expected"); }
public virtual void TestGetAttributeNameValuePairsDateWithDatePatternInformation() { // used as expected: a date object is passed in PlatformDate calendar1 = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null , null, false), new DateWithPattern(calendar1, "yyyyMMddHHmmss"), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("19990423101112", result.SafeGet("value"), "value as expected"); }
private void HandleVersion(SpecificationVersion version, string expected, bool withTimeZone) { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null , null, false, version, null, null, null, false), calendar, null); Assert.AreEqual(1, result.Count, "map size"); string expectedValue = withTimeZone ? expected + GetCurrentTimeZone(calendar) : expected; Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected"); }
public virtual void TestGetAttributeNameValuePairsDateWithMillisAndTimezoneDatePatternInformation() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null , null, false, SpecificationVersion.R02_04_02, null, null, null, false), new DateWithPattern(calendar, "yyyyMMddHHmmss.SSSZZZZZ" ), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); // SPD: hard to verify result date string since it is timezone dependent. we check length instead Assert.AreEqual("yyyyMMddHHmmss.SSSZZZZZ".Length, result.SafeGet("value").Length, "value length as expected"); }
public virtual void TestGetAttributeNameValuePairsValidDatePatternMissingTimezone() { // used as expected: a date object is passed in PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0); DateWithPattern dateWithValidPatternMissingTZ = new DateWithPattern(calendar, "yyyyMMddHH"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATETIME", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false), dateWithValidPatternMissingTZ, null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("1999042310", result.SafeGet("value"), "value as expected"); Assert.AreEqual(1, xmlResult.GetHl7Errors().Count); Assert.IsTrue(xmlResult.GetHl7Errors()[0].GetMessage().Contains("ZZZZZ")); }