示例#1
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");
        }
示例#2
0
 private void verifySchema(SIEEFieldlist schema)
 {
     if (schema.Where(n => n.ExternalId == null || n.ExternalId == string.Empty).Count() > 0)
     {
         throw new Exception("ExternalID null or empty");
     }
     if (schema.Select(n => n.ExternalId).Distinct().Count() != schema.Count())
     {
         throw new Exception("ExternamIDs are not distinct");
     }
 }