Example #1
0
        public virtual void TestFormatSearchMustHaveAtLeastOnePartType()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            formatter.Format(GetContext("addr", "AD.SEARCH"), new ADImpl(address));
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Example #2
0
        public virtual void TestFormatValidSearch()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            string formattedAddress = formatter.Format(GetContext("addr", "AD.SEARCH"), new ADImpl(address));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual("<addr><city>Toronto</city></addr>", formattedAddress.Trim());
        }
Example #3
0
        public virtual void TestFormatValueNonNull()
        {
            AdPropertyFormatter formatter     = new AdPropertyFormatter();
            PostalAddress       postalAddress = new PostalAddress();

            postalAddress.AddPostalAddressPart(new PostalAddressPart("something"));
            string result = formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(postalAddress));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(5, this.result.GetHl7Errors().Count);
            // city/state/postalcode/country are mandatory; part without types not allowed
            Assert.AreEqual("<addr></addr>", result.Trim(), "empty address node node");
        }
Example #4
0
        public virtual void TestFormatSearchCannotHaveUses()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            string formattedAddress = formatter.Format(GetContext("addr", "AD.SEARCH"), new ADImpl(address));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual("<addr><city>Toronto</city></addr>", formattedAddress.Trim());
        }
Example #5
0
        public virtual void TestFormatInvalidUseOfCodeAndCodeSystem()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, CodeUtil.ConvertToCode("Toronto", "1.2.3.4.5"
                                                                                                                  )));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Example #6
0
        public virtual void TestFormatDuplicatePartTypesAllowed()
        {
            // confirmed via Sam that all part types can occur multiple times
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "US"));
            formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));
            Assert.IsTrue(this.result.IsValid());
        }
Example #7
0
        public virtual void TestFormatValueReservedXmlChars()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "<cats think they're > humans & dogs 99% of the time/>"
                                                               ));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            string result = formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual("<addr><city>&lt;cats think they&apos;re &gt; humans &amp; dogs 99% of the time/&gt;</city><state>ON</state><postalCode>H0H0H0</postalCode><country>Canada</country></addr>"
                            .Trim(), result.Trim(), "something in text node");
        }
Example #8
0
        public virtual void TestFormatInvalidPartTypeForFull()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.DELIVERY_INSTALLATION_TYPE, "this isn't allowed"
                                                               ));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Example #9
0
        public virtual void TestFormatValueTooLong()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
                                                               ));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "123456789012345678901234567890123456789012345678901234567890123456789012345678901"
                                                               ));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Example #10
0
        public virtual void TestFormatValueNonNullMultipleAddressParts()
        {
            AdPropertyFormatter formatter     = new AdPropertyFormatter();
            PostalAddress       postalAddress = new PostalAddress();

            postalAddress.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "cityname"));
            postalAddress.AddPostalAddressPart(new PostalAddressPart("freeform"));
            postalAddress.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.DELIMITER, ","));
            postalAddress.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            string result = formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(postalAddress));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(3, this.result.GetHl7Errors().Count);
            // no parts without part type; postal code and country mandatory
            Assert.AreEqual("<addr><city>cityname</city><delimiter>,</delimiter><state>ON</state></addr>", result.Trim(), "something in text node with goofy sub nodes suppressed"
                            );
        }
Example #11
0
        public virtual void TestFormatPostalAddressUses()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.PHYSICAL);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            // since the uses as a set, order is not guaranteed
            string result = formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));

            Assert.IsTrue(this.result.IsValid());
            Assert.IsTrue(result.StartsWith("<addr use=\""), "open tag");
            Assert.IsTrue(result.Contains("\"H PHYS\"") || result.Contains("\"H PHYS\""), "H PHYS");
        }
Example #12
0
        public virtual void TestFormatTooManyPostalAddressUses()
        {
            AdPropertyFormatter formatter = new AdPropertyFormatter();
            PostalAddress       address   = new PostalAddress();

            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.HOME);
            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.PHYSICAL);
            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.DIRECT);
            address.AddUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_BasicPostalAddressUse.CONFIDENTIAL);
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.CITY, "Toronto"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.STATE, "ON"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.POSTAL_CODE, "H0H0H0"));
            address.AddPostalAddressPart(new PostalAddressPart(PostalAddressPartType.COUNTRY, "Canada"));
            string result = formatter.Format(GetContext("addr", "AD.FULL"), new ADImpl(address));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.IsTrue(result.StartsWith("<addr use=\""), "open tag");
            Assert.IsTrue(result.Contains("\"H PHYS DIR CONF\""));
        }