Beispiel #1
0
        public void TestDDNodeXmlSerializationWithoutAttributeCollection()
        {
            var stream = UTestDrDataCommon.GetMemoryStreamFromFile();

            stream.Position = 0;
            var deserialized = XMLDeserialize(stream); // check looping
        }
Beispiel #2
0
        private void ValidateXMLDeserialization(DDValue original, MemoryStream xml)
        {
            xml.Position = 0;
            var deserialyzed = XMLDeserialyze(xml);

            UTestDrDataCommon.WriteMemmoryStreamToXmlFile(xml);
            ValidateDeserialization(original, (DDValue)deserialyzed);
        }
Beispiel #3
0
        public static void ValidateXMLDeserialization(DDNode original, MemoryStream xml)
        {
            xml.Position = 0;
            UTestDrDataCommon.WriteMemmoryStreamToXmlFile(xml);
            var deserialized = XMLDeserialize(xml);

            ValidateDeserialization(original, (DDNode)deserialized);
        }
Beispiel #4
0
        public void TestDDNodeXmlDeserializationFromFileLegacyAttributeCollection()
        {
            var n = new DDNode("name", "type");

            n.Attributes.Add("bool", true);
            n.Attributes.Add("int", 1);
            ValidateXMLDeserialization(n, UTestDrDataCommon.GetMemoryStreamFromFile());
        }
        private void ValidateXMLDeserialization(DDAttributesCollection original, MemoryStream xml)
        {
            xml.Position = 0;
            UTestDrDataCommon.WriteMemmoryStreamToXmlFile(xml);
            var deserialized = XMLDeserialize(xml);

            ValidateDeserialization(original, (DDAttributesCollection)deserialized);
        }
Beispiel #6
0
        private void ValidateDeserialization(DDValue original, IFormatter iFormatter, Stream stream)
        {
            stream.Position = 0;
            UTestDrDataCommon.WriteMemmoryStreamToBinFile((MemoryStream)stream);
            var deserialyzed = (DDValue)DeserializeItem(stream, iFormatter);

            ValidateDeserialization(original, deserialyzed);
        }
Beispiel #7
0
        public void TestDDNodeXmlDeserializationFromFileLegacyAttributeCollectionWithHierarchy()
        {
            var n = new DDNode("name", "type");

            n.Attributes.Add("bool", false);
            n.Attributes.Add("int", -1);
            n.Add("ChildNode").Add("SubChildNode").Attributes.Add("string", "string");
            ValidateXMLDeserialization(n, UTestDrDataCommon.GetMemoryStreamFromFile());
        }
        public void TestDDAttributesCollectionXmlSerializationFromFileSkipIncorrectValue()
        {
            var a = new DDAttributesCollection();

            a.Add(string.Empty, null);
            a.Add("A", null);
            a.Add("B", new DDValue(new string[] { "", "Value_A", "Value_B" }));
            ValidateXMLDeserialization(a, UTestDrDataCommon.GetMemoryStreamFromFile());
        }
Beispiel #9
0
        public void TestDeserializationFromXMLAndAutoNameGeneration()
        {
            var n = DDNodeSxe.Deserialize(UTestDrDataCommon.GetMemoryStreamFromFile());

            Assert.IsTrue(n.Type == String.Empty, "Type of nodes are not equals after deserialization with auto node name generation.");
            foreach (var c in n)
            {
                Assert.IsTrue(c.Value.Type == "Type", "Type of nodes are not equals after deserialization with auto node name generation.");
                var en = c.Value.Attributes.GetEnumerator();

                en.MoveNext();
            }
        }
Beispiel #10
0
        private void TestMergeNodeWithAnotherNode(DDNode nDestination, DDNode.DDNODE_MERGE_OPTION option, ResolveConflict res)
        {
            var nSource = XMLDeserialize(UTestDrDataCommon.GetMemoryStreamFromFile(".\\XML\\" + UTestDrDataCommon.GetTestMethodName() + ".Source.xml"));

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nDestination), UTestDrDataCommon.GetTestMethodName() + ".Destination.xml");
            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nSource), UTestDrDataCommon.GetTestMethodName() + ".Source.xml");

            nDestination.Merge(nSource, option, res);

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nDestination), UTestDrDataCommon.GetTestMethodName() + ".Actual.xml");
            var nExpected = XMLDeserialize(UTestDrDataCommon.GetMemoryStreamFromFile(".\\XML\\" + UTestDrDataCommon.GetTestMethodName() + ".Expected.xml"));

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nExpected), UTestDrDataCommon.GetTestMethodName() + ".Expected.xml");

            Assert.IsTrue(nDestination == nExpected, "The actual node is not equal expected node. See xml files in the bin folder.");
        }
Beispiel #11
0
        public void TestMergeStockCollectionWithEmptyCollection()
        {
            var nDestination = GetStockHierarhy();
            var nSource      = new DDNode("Test");

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nDestination), UTestDrDataCommon.GetTestMethodName() + ".Destination.xml");
            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nSource), UTestDrDataCommon.GetTestMethodName() + ".Source.xml");

            nDestination.Merge(nSource);

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nDestination), UTestDrDataCommon.GetTestMethodName() + ".Actual.xml");
            var nExpected = XMLDeserialize(UTestDrDataCommon.GetMemoryStreamFromFile(".\\XML\\" + UTestDrDataCommon.GetTestMethodName() + ".Expected.xml"));

            UTestDrDataCommon.WriteMemmoryStreamToFile(XMLSerialize(nExpected), UTestDrDataCommon.GetTestMethodName() + ".Expected.xml");

            Assert.IsTrue(nDestination == nExpected, "The actual node is not equal expected node. See xml files in the bin folder.");
        }
 public void TestDDAttributesCollectionXmlSerializationFromFileEmpty()
 {
     ValidateXMLDeserialization(new DDAttributesCollection(), UTestDrDataCommon.GetMemoryStreamFromFile());
 }
Beispiel #13
0
 public static void WriteMemmoryStreamToBinFile(MemoryStream stream)
 {
     WriteMemmoryStreamToFile(stream, UTestDrDataCommon.GetTestMethodName() + ".bin");
 }
Beispiel #14
0
 public void TestDDValueXmlSerializationFromFileEmptyString()
 {
     ValidateXMLDeserialization(new DDValue(string.Empty), UTestDrDataCommon.GetMemoryStreamFromFile());
 }
Beispiel #15
0
 public void TestDDValueXmlSerializationFromFileSkippIncorrectedNodeTypeStringEmpty()
 {
     ValidateXMLDeserialization(new DDValue(string.Empty), UTestDrDataCommon.GetMemoryStreamFromFile());
 }
Beispiel #16
0
 public void TestDDValueXmlSerializationFromFileSkippIncorrectedNodeTypeStringArrayDeepWithValue()
 {
     ValidateXMLDeserialization(new DDValue(new string[] { "TestValue", "TheLastValue" }), UTestDrDataCommon.GetMemoryStreamFromFile());
 }
Beispiel #17
0
 public void TestDDNodeXmlSerializationFromFileSkipIncorrectedData()
 {
     ValidateXMLDeserialization(GetStockHierarhy(), UTestDrDataCommon.GetMemoryStreamFromFile());
 }
Beispiel #18
0
 public void TestDDValueXmlSerializationNullFromXML()
 {
     ValidateXMLDeserialization(new DDValue(), UTestDrDataCommon.GetMemoryStreamFromString("<" + DrOpen.DrData.DrDataSx.DDSchema.XML_SERIALIZE_NODE_VALUE + " t='" + DrOpen.DrData.DrDataSx.DDSchema.XML_SERIALIZE_VALUE_TYPE_NULL + "' />"));
 }