Exemplo n.º 1
0
        public void TestLoad()
        {
            DataTable entityTable = new DataTable("EntityTable");
            entityTable.Columns.Add("EntityId", typeof(int));
            entityTable.Columns.Add("Value", typeof(string));
            entityTable.Columns.Add("Custom", typeof(int));
            entityTable.Columns.Add("Xml", typeof(string));
            entityTable.Columns.Add("PropertyValue", typeof(string));
            entityTable.Rows.Add(1, "Entity", 2, "<string>string</string>", "1");
            entityTable.AcceptChanges();
            string entityAsXml = XmlSerializationHelper.SerializeDataTable(entityTable, true);
            Trace.WriteLine(entityAsXml);

            TestEntity entity = new TestEntity();
            DataRow entityRow = entityTable.Rows[0];
            entity.Load(entityRow);

            Assert.AreEqual(entity.EntityId, (int)entityRow["EntityId"]);
            Assert.AreEqual(entity.Value, (string)entityRow["Value"]);
            Assert.AreEqual(entity.CustomValue, "2");
            Assert.AreEqual(entity.XmlValue, "string");
            Assert.AreEqual(entity.PropertyValue, "1");
        }