Beispiel #1
0
        public virtual void TestFormatValueNull()
        {
            FormatContext context = GetContext("name");
            string        result  = new MoR2PropertyFormatter().Format(context, new MOImpl((Money)null));

            Assert.AreEqual("<name nullFlavor=\"NI\"/>", result.Trim(), "named null format");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
        }
Beispiel #2
0
        public virtual void TestFormatSxcmValueNonNullWithNoOperator()
        {
            MoR2PropertyFormatter formatter = new MoR2PropertyFormatter();
            Money         money             = new Money(new BigDecimal("12.00"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR);
            FormatContext context           = GetContext("amount", "SXCM<TS>");
            MOImpl        dataType          = new MOImpl(money);
            string        result            = formatter.Format(context, dataType);

            Assert.AreEqual("<amount currency=\"CAD\" value=\"12.00\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
        }
Beispiel #3
0
        public virtual void TestFormatValueNonNullWithOperatorNotAllowed()
        {
            MoR2PropertyFormatter formatter = new MoR2PropertyFormatter();
            Money         money             = new Money(new BigDecimal("12.00"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR);
            FormatContext context           = GetContext("amount");
            MOImpl        dataType          = new MOImpl(money);

            dataType.Operator = SetOperator.CONVEX_HULL;
            string result = formatter.Format(context, dataType);

            Assert.AreEqual("<amount currency=\"CAD\" value=\"12.00\"/>", result.Trim(), "something in text node");
            Assert.IsFalse(context.GetModelToXmlResult().IsValid());
            Assert.AreEqual(1, context.GetModelToXmlResult().GetHl7Errors().Count);
            Assert.IsTrue(context.GetModelToXmlResult().GetHl7Errors()[0].GetMessage().ToLower().Contains("operator"));
        }
Beispiel #4
0
        public virtual void TestFormatValueNonNull()
        {
            MoR2PropertyFormatter formatter = new MoR2PropertyFormatter();
            Money         money             = new Money(new BigDecimal("12.00"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR);
            FormatContext context           = GetContext("amount");
            string        result            = formatter.Format(context, new MOImpl(money));

            Assert.AreEqual("<amount currency=\"CAD\" value=\"12.00\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money  = new Money(new BigDecimal("12"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR);
            result = formatter.Format(context, new MOImpl(money));
            Assert.AreEqual("<amount currency=\"CAD\" value=\"12\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money  = new Money(new BigDecimal("12.0000"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.EURO);
            result = formatter.Format(context, new MOImpl(money));
            Assert.AreEqual("<amount currency=\"EUR\" value=\"12.0000\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money  = new Money(null, Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.EURO);
            result = formatter.Format(context, new MOImpl(money));
            Assert.AreEqual("<amount currency=\"EUR\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money  = new Money(new BigDecimal("12.0000"), null);
            result = formatter.Format(context, new MOImpl(money));
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money = new Money(new BigDecimal("123456789012.00"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR
                              );
            result = formatter.Format(context, new MOImpl(money));
            Assert.AreEqual("<amount currency=\"CAD\" value=\"123456789012.00\"/>", result.Trim(), "something in text node");
            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            context.GetModelToXmlResult().ClearErrors();
            money  = new Money(new BigDecimal("-89012.00"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR);
            result = formatter.Format(context, new MOImpl(money));
            Assert.AreEqual("<amount currency=\"CAD\" value=\"-89012.00\"/>", result.Trim(), "something in text node");
            Assert.IsFalse(context.GetModelToXmlResult().IsValid());
            Assert.AreEqual(1, context.GetModelToXmlResult().GetHl7Errors().Count);
        }