Пример #1
0
        public virtual void TestGetAttributeNameValuePairsIncludeUses()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "value";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONE"), address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:value", result.SafeGet("value"), "value as expected");
            Assert.IsTrue(result.ContainsKey("use"), "use key as expected");
            Assert.AreEqual("H", result.SafeGet("use"), "use as expected");
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest(
                CreateContext("TEL.PHONE"), address, new TELImpl());
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("use"), "use key as expected");
            ICollection <string> uses = FormatterAssert.ToSet(result.SafeGet("use"));

            FormatterAssert.AssertContainsSame("uses", FormatterAssert.ToSet("H MC"), uses);
        }
Пример #2
0
        public virtual void TestIncludeUses()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "aValue";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H\" value=\"tel:aValue\"/>", result);
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));
            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H MC\" value=\"tel:aValue\"/>", result);
        }
Пример #3
0
        public virtual void TestIncludeUsesAndUseablePeriods()
        {
            PlatformDate             date1   = DateUtil.GetDate(2004, 5, 10, 9, 42, 43, 123);
            PlatformDate             date2   = DateUtil.GetDate(2006, 6, 11, 11, 31, 32, 444);
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "aValue";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            address.AddUseablePeriod(new DateWithPattern(date1, "yyyyMMddHHmmss.SSS0"), SetOperator.EXCLUDE);
            address.AddUseablePeriod(new DateWithPattern(date2, "yyyyMMddHHmmss.SSS0"), null);
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H MC\" value=\"tel:aValue\"><useablePeriod operator=\"E\" value=\"20040610094243.1230\"/><useablePeriod operator=\"I\" value=\"20060711113132.4440\"/></name>"
                      , result);
        }
Пример #4
0
        private void AssertInvalidAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse addressUse)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FAX;
            address.Address   = "4167620032";
            address.AddAddressUse(addressUse);
            this.xmlResult.ClearErrors();
            new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext
                                                                                                                                ("TEL.PHONE"), address, new TELImpl());
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual("TelecomAddressUse is not valid: " + addressUse.CodeValue, this.xmlResult.GetHl7Errors()[0].GetMessage(),
                            "expected message");
        }
Пример #5
0
        public virtual void TestTextContent()
        {
            TelecommunicationAddress reference = new TelecommunicationAddress();

            reference.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            reference.Address   = "aValue";
            reference.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            EncapsulatedData data   = CreateEd(reference, "some content &amp; that will <b>not</b> be escaped");
            string           result = new EdPropertyFormatter(this.telFormatter, true).Format(GetContext("text", "ED"), new EDImpl <EncapsulatedData
                                                                                                                                    >(data));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("something in text node", "<text compression=\"ZL\" integrityCheck=\"c29tZXRoaW5nIHRvIGVuY29kZQ==\" integrityCheckAlgorithm=\"SHA-256\" language=\"en-CA\" mediaType=\"text/plain\" representation=\"TXT\">"
                      + "<reference use=\"H\" value=\"tel:aValue\"/>" + "some content &amp; that will <b>not</b> be escaped" + "</text>", result
                      , true);
        }
Пример #6
0
        public virtual void TestInvalidTextContent()
        {
            TelecommunicationAddress reference = new TelecommunicationAddress();

            reference.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            reference.Address   = "aValue";
            reference.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            try
            {
                CreateEd(reference, "some content & that will <b>not</b> be escaped");
                Assert.Fail("Should not get here due to unescaped content");
            }
            catch (SAXException)
            {
            }
        }
Пример #7
0
        /// <exception cref="System.Exception"></exception>
        private void AssertValidAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse addressUse)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FAX;
            address.AddAddressUse(addressUse);
            address.Address = "someAddress";
            this.xmlResult.ClearErrors();
            Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = CreateContext("TEL.PHONE");
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (context, address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("use"), "key as expected");
            Assert.AreEqual(addressUse.CodeValue, result.SafeGet("use"), "value as expected");
        }
Пример #8
0
        public virtual void TestGetAttributeNameValuePairsAllInvalidUsesForCerxPhone()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FAX;
            address.Address   = "value";
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.ANSWERING_MACHINE);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.BAD);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.CONFIDENTIAL);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.DIRECT);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.EMERGENCY_CONTACT);
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.HOME);
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.MOBILE);
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.PAGER);
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.PRIMARY_HOME);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.PUBLISHED);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.TEMPORARY);
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.VACATION_HOME);
            // invalid
            address.AddAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.WORKPLACE);
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONE", SpecificationVersion.V01R04_3), address, new TELImpl());

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(8, this.xmlResult.GetHl7Errors().Count);
            // 7 bad uses + 1 for too many
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("fax:value", result.SafeGet("value"), "value as expected");
            ICollection <string> uses = FormatterAssert.ToSet(result.SafeGet("use"));

            FormatterAssert.AssertContainsSame("uses", FormatterAssert.ToSet("EC H MC PG TMP WP"), uses);
        }