Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public virtual void TestGetAttributeNameValuePairsNullValue()
        {
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONE"), null, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            // a null value for TEL.PHONEMAIL elements results in a nullFlavor attribute
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey(AbstractPropertyFormatter.NULL_FLAVOR_ATTRIBUTE_NAME), "key as expected");
            Assert.AreEqual(AbstractPropertyFormatter.NULL_FLAVOR_NO_INFORMATION, result.SafeGet("nullFlavor"), "value as expected");
        }
Ejemplo n.º 3
0
        public virtual void TestGetAttributeNameValuePairsTelPhonemailValid()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

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

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:value", result.SafeGet("value"), "value as expected");
        }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
0
        public virtual void TestGetAttributeNameValuePairsTelAllMissingSpecializationType()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

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

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual(3, result.Count, "map size");
            // ST and xsi:type are provided after detecting invalid/missing ST
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:value", result.SafeGet("value"), "value as expected");
            Assert.IsTrue(result.ContainsKey("specializationType"), "key as expected");
            Assert.AreEqual("TEL.PHONE", result.SafeGet("specializationType"), "value as expected");
            Assert.IsTrue(result.ContainsKey("xsi:type"), "key as expected");
            Assert.AreEqual("TEL", result.SafeGet("xsi:type"), "value as expected");
        }
Ejemplo n.º 6
0
        public virtual void TestGetAttributeNameValuePairsTelPhonemailWithSpecializationType()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "value";
            TELImpl bareAny = new TELImpl();

            bareAny.DataType = StandardDataType.TEL_PHONE;
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONEMAIL"), address, bareAny);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(3, 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("specializationType"), "key as expected");
            Assert.AreEqual("TEL.PHONE", result.SafeGet("specializationType"), "value as expected");
            Assert.IsTrue(result.ContainsKey("xsi:type"), "key as expected");
            Assert.AreEqual("TEL", result.SafeGet("xsi:type"), "value as expected");
        }
Ejemplo n.º 7
0
        public virtual void TestGetAttributeNameValuePairsAllInvalidUsesForEmail()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.MAILTO;
            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);
            // invalid
            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.EMAIL"), address, new TELImpl());

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

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