Beispiel #1
0
        public virtual void TestFormatValueNull()
        {
            string expectedResult = "<name nullFlavor=\"NI\"/>" + SystemUtils.LINE_SEPARATOR;
            string result         = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>());

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(expectedResult, result, "named null format");
        }
Beispiel #2
0
        public virtual void TestReferenceForSKBug()
        {
            string           expectedResult = "<text mediaType=\"text/html\"><reference value=\"https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html\"/></text>";
            EncapsulatedData data           = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HTML_TEXT, "https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html"
                                                                   , null, null);
            string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOCREF"), new EDImpl <EncapsulatedData>(data));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node");
        }
Beispiel #3
0
        public virtual void TestFormatValueWithNoMediaType()
        {
            string expectedResult = "<name>" + "this is some text</name>" + SystemUtils.LINE_SEPARATOR;
            string result         = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(new EncapsulatedData
                                                                                                                                     (null, null, null, System.Text.ASCIIEncoding.ASCII.GetBytes("this is some text"))));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            AssertXml("something in text node", expectedResult, result, true);
        }
Beispiel #4
0
        public virtual void TestFormatValueMissingContent()
        {
            string expectedResult = "<name mediaType=\"text/plain\"/>";
            string result         = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(new EncapsulatedData
                                                                                                                                     (Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, null, null, System.Text.ASCIIEncoding.ASCII.GetBytes
                                                                                                                                         (string.Empty))));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual(expectedResult, result, "something in text node");
        }
Beispiel #5
0
        public virtual void TestFormatValueNonNull()
        {
            string expectedResult = "<name mediaType=\"text/plain\">" + "this is some text &amp; some &quot;more&quot;</name>" + SystemUtils
                                    .LINE_SEPARATOR;
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(new EncapsulatedData
                                                                                                                             (Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, null, null, System.Text.ASCIIEncoding.ASCII.GetBytes
                                                                                                                                 ("this is some text & some \"more\""))));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("something in text node", expectedResult, result, true);
        }
Beispiel #6
0
        public virtual void TestMissingReference()
        {
            string           expectedResult = "<text mediaType=\"text/html\"/>";
            EncapsulatedData data           = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.HTML_TEXT, null
                                                                   , null, null);
            string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOCREF"), new EDImpl <EncapsulatedData>(data));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node");
        }
Beispiel #7
0
        public virtual void TestReferenceWithContent()
        {
            string           expectedResult = "<text mediaType=\"text/plain\"><reference value=\"https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html\"/>this is some text</text>";
            EncapsulatedData data           = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT,
                                                                   "https://pipefq.ehealthsask.ca/monograph/WPDM00002197.html", null, System.Text.ASCIIEncoding.ASCII.GetBytes("this is some text"
                                                                                                                                                                               ));
            string result = new EdPropertyFormatter().Format(GetContext("text", "ED.DOC"), new EDImpl <EncapsulatedData>(data));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node");
        }
Beispiel #8
0
        public virtual void TestFormatValueReservedXmlChars()
        {
            string expectedResult = "<name mediaType=\"text/plain\">&lt;cats think they&apos;re &gt; humans &amp; dogs 99% of the time/&gt;</name>"
                                    + SystemUtils.LINE_SEPARATOR;
            EncapsulatedData ed = new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, null
                                                       , null, System.Text.ASCIIEncoding.ASCII.GetBytes("<cats think they're > humans & dogs 99% of the time/>"));
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(ed));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("something in text node", expectedResult.Trim(), result.Trim(), true);
        }
Beispiel #9
0
        public virtual void TestFormatValueWithMissingSpecializationType()
        {
            string expectedResult = "<name mediaType=\"text/plain\" specializationType=\"ED.DOC\" xsi:type=\"ED\">" + "this is some text &amp; some &quot;more&quot;</name>"
                                    + SystemUtils.LINE_SEPARATOR;
            EDImpl <EncapsulatedData> edImp = new EDImpl <EncapsulatedData>(new EncapsulatedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType
                                                                                                 .PLAIN_TEXT, null, null, System.Text.ASCIIEncoding.ASCII.GetBytes("this is some text & some \"more\"")));
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOCORREF"), edImp);

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            AssertXml("something in text node", expectedResult, result, true);
        }
Beispiel #10
0
        public virtual void TestFormatValueCompressedXmlDataEmptyContent()
        {
            byte[]           content        = System.Text.ASCIIEncoding.ASCII.GetBytes(string.Empty);
            string           expectedResult = "<name compression=\"GZ\" language=\"en-CA\" mediaType=\"text/xml\"/>" + SystemUtils.LINE_SEPARATOR;
            EncapsulatedData data           = new CompressedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.XML_TEXT, null
                                                                 , content, Compression.GZIP, "en-CA");
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(data));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual(ClearPayload(expectedResult), ClearPayload(result), "element");
        }
Beispiel #11
0
        public virtual void TestFormatValueCompressedXmlDataNullContent()
        {
            string           expectedResult = "<name compression=\"GZ\" language=\"en-CA\" mediaType=\"text/xml\"><reference value=\"http://www.i-proving.ca\"/></name>";
            EncapsulatedData data           = new CompressedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.XML_TEXT, null
                                                                 , null, Compression.GZIP, "en-CA");

            data.ReferenceObj = new TelecommunicationAddress(Ca.Infoway.Messagebuilder.Domainvalue.Basic.URLScheme.HTTP, "www.i-proving.ca"
                                                             );
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(data));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual(expectedResult, ClearPayload(result), "something in text node");
        }
Beispiel #12
0
        public virtual void TestFormatValueCompressedTextData()
        {
            string contentAsString = "<xml>foo</xml>";

            byte[] content        = System.Text.ASCIIEncoding.ASCII.GetBytes(contentAsString);
            string finalContent   = Base64.EncodeBase64String(Compression.Gzip(content));
            string expectedResult = "<name compression=\"GZ\" language=\"en-CA\" mediaType=\"text/plain\" representation=\"B64\">" +
                                    finalContent + "</name>" + SystemUtils.LINE_SEPARATOR;
            EncapsulatedData data = new CompressedData(Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT, null
                                                       , System.Text.ASCIIEncoding.ASCII.GetBytes(finalContent), Compression.GZIP, "en-CA");

            data.Representation = EdRepresentation.B64;
            string result = new EdPropertyFormatter().Format(GetContext("name", "ED.DOC"), new EDImpl <EncapsulatedData>(data));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(ClearPayload(expectedResult), ClearPayload(result), "element");
            Assert.AreEqual(DecodeAndUnzip(ExtractPayload(result)), contentAsString, "element payload");
        }