Exemplo n.º 1
0
        public void t11_TargetDocumentId()
        {
            // Create xml document
            XmlDocument data = createDataPool().RootNode.InnerXmlNode.OwnerDocument;

            // We use a dedicated SIEE_Adapter for this test.  We must first register it in the FactoryManager.
            SIEEFactory factory = new Test_SIEEFactory();

            SIEEFactoryManager.Add(factory);

            // We use a default SIEE_Adapter_Settings object and set the Schema
            EECWriterSettings adapterSettings = createWriterSettings(new SIEEFieldlist());

            SIEEWriterExport adapterExport = new SIEEWriterExport();

            adapterExport.Configure(adapterSettings);

            Test_SIEEExport.ExportFunc = (settings, doc, name, fieldlist) =>
            {
                doc.TargetDocumentId = "4711";
            };

            DataPool pool = new DataPool(adapterExport.transform(data, null));

            Assert.AreEqual("4711", pool.RootNode.Documents[0].Annotations["TargetDocumentId"].Value);
            Assert.AreEqual("SIEE_Adapter", pool.RootNode.Documents[0].Annotations["TargetType"].Value);
        }
Exemplo n.º 2
0
        public void t09_SIEEAnnotation()
        {
            // Create a data pool
            DataPool pool = createDataPool();

            pool.RootNode.Documents[0].Fields["field1"].Value = "field1value";

            // Create an xml document from the data pool
            XmlDocument data;

            data = pool.RootNode.InnerXmlNode.OwnerDocument;

            // We use a dedicated SIEE_Adapter for this test.  We must first register it in the FactoryManager.
            SIEEFactory factory = new Test_SIEEFactory();

            SIEEFactoryManager.Add(factory);

            // We use a default SIEE_Adapter_Settings object and set the Schema
            EECWriterSettings adapterSettings = createWriterSettings(new SIEEFieldlist()
            {
                { new SIEEField()
                  {
                      Name = "field1", ExternalId = ""
                  } },
                { new SIEEField()
                  {
                      Name = "field2", ExternalId = ""
                  } },
            });

            SIEEWriterExport adapterExport = new SIEEWriterExport();

            adapterExport.Configure(adapterSettings);

            Test_SIEEExport.ExportFunc = (settings, doc, name, fieldlist) =>
            {
                int val = 0;
                if (doc.SIEEAnnotation != null)
                {
                    val = int.Parse(doc.SIEEAnnotation);
                }
                if (val <= 3)
                {
                    doc.NewSIEEAnnotation = (val + 1).ToString();
                }
                throw new Exception("Some exception");
            };
            int count = 1;

            pool = new DataPool(adapterExport.transform(data, null));
            t09_testAnnotation(pool, count++);
            pool = new DataPool(adapterExport.transform(pool.RootNode.InnerXmlNode.OwnerDocument, null));
            t09_testAnnotation(pool, count++);
            pool = new DataPool(adapterExport.transform(pool.RootNode.InnerXmlNode.OwnerDocument, null));
            t09_testAnnotation(pool, count);
            pool = new DataPool(adapterExport.transform(pool.RootNode.InnerXmlNode.OwnerDocument, null));
            t09_testAnnotation(pool, count);
        }
Exemplo n.º 3
0
        public void t01_EmptyFieldHandling()
        {
            // First we create the runtime document that is to be exported.
            DataPool pool = createDataPool();

            Document doc = pool.RootNode.Documents[0];

            doc.Fields["field1"].Value = "field1value";               // should show up
            doc.Fields.Add(new Field(pool, "field2", "field2value")); // should be ignored
            doc.Fields.Add(new Field(pool, "field3", "field3value")); // should be ignored

            // Create an xml document from the data pool
            XmlDocument data = pool.RootNode.InnerXmlNode.OwnerDocument;

            EECWriterSettings adapterSettings = createWriterSettings(new SIEEFieldlist()
            {
                { new SIEEField()
                  {
                      Name = "field1", ExternalId = ""
                  } },
                { new SIEEField()
                  {
                      Name = "field2", ExternalId = ""
                  } },
                { new SIEEField()
                  {
                      Name = "field3", Value = "default value dor field3"
                  } }
            });

            SIEEWriterExport adapterExport = new SIEEWriterExport();

            adapterExport.FieldMapping4UnitTest.Add("field1");  // we just want to simulate one mapped field
            adapterExport.Configure(adapterSettings);

            SIEEFieldlist lastFieldList = null;

            Test_SIEEExport.ExportFunc = (settings, document, name, fl) =>
            {
                lastFieldList = fl;
            };
            adapterExport.transform(data, null);    // do the export

            // The test export actually has not exported anything but stored the field list internally.
            // We execute the assertions on this result field list.
            SIEEFieldlist fieldlist = lastFieldList;

            Assert.AreEqual("field1value", fieldlist.Where(n => n.Name == "field1").First().Value, "field1 != null");
            Assert.IsNull(fieldlist.Where(n => n.Name == "field2").First().Value, "field2 == null");
            Assert.AreEqual("default value dor field3", fieldlist.Where(n => n.Name == "field3").First().Value, "field3 has default value");
        }
Exemplo n.º 4
0
        public void t10_ListFieldHandling()
        {
            // First we create the runtime document that is to be exported.
            DataPool pool = createDataPool();
            Document doc  = pool.RootNode.Documents[0];

            doc.Fields["field1"].Value = "field1value";
            doc.Fields.Add(new Field(pool, "field2", "field2value"));
            doc.Fields.Add(new Field(pool, "field3", "field3value"));
            doc.Fields.Add(new Field(pool, "field4", "field4value"));
            doc.Fields.Add(new Field(pool, "field5", "field5value"));
            doc.Fields.Add(new Field(pool, "field6", "field6value"));

            addFieldList(pool, doc.Fields["field1"], 2);    // to ba ignored
                                                            // field2 --> no list
            addFieldList(pool, doc.Fields["field3"], 2);    // fewer subfields
            addFieldList(pool, doc.Fields["field4"], 4);    // exact
            addFieldList(pool, doc.Fields["field5"], 6);    // more sub fields
            addFieldList(pool, doc.Fields["field6"], 42);   // no limits

            // Create an xml document from the data pool
            XmlDocument data;

            data = pool.RootNode.InnerXmlNode.OwnerDocument;

            EECWriterSettings adapterSettings = createWriterSettings(new SIEEFieldlist()
            {
                { new SIEEField()
                  {
                      Name = "field1",
                  } },
                { new SIEEField()
                  {
                      Name = "field2", Cardinality = 2
                  } },
                { new SIEEField()
                  {
                      Name = "field3", Cardinality = 3
                  } },
                { new SIEEField()
                  {
                      Name = "field4", Cardinality = 4
                  } },
                { new SIEEField()
                  {
                      Name = "field5", Cardinality = 5
                  } },
                { new SIEEField()
                  {
                      Name = "field6", Cardinality = -1
                  } },
            });

            SIEEWriterExport adapterExport = new SIEEWriterExport();

            adapterExport.FieldMapping4UnitTest.Add("field1");
            adapterExport.FieldMapping4UnitTest.Add("field2");
            adapterExport.FieldMapping4UnitTest.Add("field3");
            adapterExport.FieldMapping4UnitTest.Add("field4");
            adapterExport.FieldMapping4UnitTest.Add("field5");
            adapterExport.FieldMapping4UnitTest.Add("field6");

            adapterExport.Configure(adapterSettings);

            SIEEFieldlist lastFieldList = null;

            Test_SIEEExport.ExportFunc = (settings, document, name, fl) =>
            {
                lastFieldList = fl;
            };
            adapterExport.transform(data, null);    // do the export

            // The test export actually has not exported anything but stored the field list internally.
            // We execute the assertions on this result field list.
            SIEEFieldlist fieldlist = lastFieldList;

            verfiyValueList(lastFieldList, "field1", "field1value", 0);
            verfiyValueList(lastFieldList, "field2", "field2value", 0);
            verfiyValueList(lastFieldList, "field3", "field3value", 2);
            verfiyValueList(lastFieldList, "field4", "field4value", 4);
            verfiyValueList(lastFieldList, "field5", "field5value", 5);
            verfiyValueList(lastFieldList, "field6", "field6value", 42);
        }