Example #1
0
        public void SerializeToXML_ValidXML_Expect_Sucess()
        {
            ErrorResultTO       errors;
            string              error;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);

            byte[]          data = (TestHelper.ConvertStringToByteArray(DataListWellformedData));
            IBinaryDataList obj  = xmlConverter.ConvertTo(data, _dataListWellformed, out errors);

            IBinaryDataListEntry entry;

            if (obj.TryGetEntry("rs1", out entry, out error))
            {
                IList <IBinaryDataListItem> cols = entry.FetchRecordAt(1, out error);
                int systemTagCount = Enum.GetValues(typeof(enSystemTag)).Length;

                var res1 = obj.FetchAllEntries().Count;
                var res2 = obj.FetchScalarEntries().Count;
                var res3 = obj.FetchRecordsetEntries().Count;
                var res4 = cols.Count;

                Assert.AreEqual(3 + systemTagCount, res1);
                Assert.AreEqual(2 + systemTagCount, res2);
                Assert.AreEqual(1, res3);
                Assert.AreEqual(2, res4);
            }
            else
            {
                Assert.Fail("Error");
            }
        }
Example #2
0
        public void SerializeToXML_InValidXML_Expect_Error()
        {
            ErrorResultTO       errors;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);

            byte[] data = (TestHelper.ConvertStringToByteArray(_dataListMalformed.ToString()));
            xmlConverter.ConvertTo(data, _dataListMalformed, out errors);

            // convert fails, hence no datalist cleanup ;)

            Assert.AreEqual("The 'rs1' start tag on line 1 position 22 does not match the end tag of 'DataList'. Line 1, position 53.", errors.FetchErrors()[0]);
        }
Example #3
0
        public void SerializeToXML_ValidXML_BlankXML_Expect_Blank_Values_Returned()
        {
            string              error;
            ErrorResultTO       errors;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);

            byte[]          data = (TestHelper.ConvertStringToByteArray(""));
            IBinaryDataList obj  = xmlConverter.ConvertTo(data, _dataListWellformedDescAttributes, out errors);

            IList <IBinaryDataListEntry> scalars    = obj.FetchScalarEntries();
            IList <IBinaryDataListEntry> recordsets = obj.FetchRecordsetEntries();
            IBinaryDataListItem          item       = scalars[0].FetchScalar();
            IList <IBinaryDataListItem>  items      = recordsets[0].FetchRecordAt(1, out error);

            Assert.IsTrue(item != null && items != null);
        }
Example #4
0
        public void SerializeToXML_ValidXMLWithDescriptions_Return_Decriptions_Expect_Sucess()
        {
            ErrorResultTO       errors;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);

            byte[]          data = (TestHelper.ConvertStringToByteArray(DataListWellformedDataWithDesc));
            IBinaryDataList obj  = xmlConverter.ConvertTo(data, _dataListWellformedDescAttributes, out errors);

            IList <IBinaryDataListEntry> scalars    = obj.FetchScalarEntries();
            IList <IBinaryDataListEntry> recordsets = obj.FetchRecordsetEntries();

            var res1 = scalars[0].Description;
            var res2 = recordsets[0].Columns[0].ColumnDescription;

            Assert.AreEqual("Test scalar description", res1);
            Assert.AreEqual("Test field1 desciption", res2);
        }
Example #5
0
        public void ConvertTo_XMLInputsOnlyFromBinary_ValidXML_Expect_Sucess()
        {
            ErrorResultTO       errors;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatInputsOnly);
            const string        payload      = "<DataList><rs2><f2>rec1.f2.value</f2></rs2><rs2><f2>rec2.f2.value</f2></rs2><scalar1>scalar1Value</scalar1></DataList>";
            const string        shape        = "<ADL><rs2><f2/></rs2><scalar1/></ADL>";
            var data = TestHelper.ConvertStringToByteArray(payload);

            var tmp        = xmlConverter.ConvertTo(data, shape.ToStringBuilder(), out errors);
            var recordsets = tmp.FetchRecordsetEntries();
            var scalars    = tmp.FetchScalarEntries();

            string error;

            Assert.AreEqual(1, recordsets.Count);
            var rowItems = recordsets[0].FetchRowAt(1, out error);

            Assert.AreEqual("rec1.f2.value", rowItems[0].TheValue);
            Assert.AreEqual(1, scalars.Count);
            Assert.AreEqual("scalar1Value", scalars[0].FetchScalar().TheValue);
        }