public virtual void TestGetAttributeNameValuePairsNullValue() { IDictionary <string, string> result = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(this.result, null, "name", null, null, null, false), null, new INTImpl()); // a null value for INT 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"); Assert.IsTrue(this.result.IsValid(), "no errors"); }
public virtual void TestGetAttributeNameValuePairsIntegerValid() { string integerValue = "34"; IDictionary <string, string> result = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(this.result, null, "name", null, null, null, false), System.Convert.ToInt32(integerValue), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual(integerValue, result.SafeGet("value"), "value as expected"); Assert.IsTrue(this.result.IsValid(), "no errors"); }
public virtual void TestGetAttributeNameValuePairsIntegerNegative() { string integerValue = "-1"; Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "name", "INT", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.REQUIRED, null, false); Int32?integer = System.Convert.ToInt32(integerValue); IDictionary <string, string> result = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, integer, new INTImpl(integer)); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual(integerValue, result.SafeGet("value"), "value as expected"); context.GetModelToXmlResult().ClearErrors(); string output = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().Format(context, new INTImpl(integer)); Assert.AreEqual("<name value=\"-1\"/>", output.Trim(), "xml output as expected"); Assert.IsTrue(context.GetModelToXmlResult().IsValid()); }