Exemplo n.º 1
0
        public void TestDataRow()
        {
            DataTable dt = EntityTools <DataObjectModel> .Table.Clone();

            DataObjectModel obj = new DataObjectModel();

            DataRow row = dt.NewRow();

            foreach (DataColumn c in dt.Columns)
            {
                if (c.DataType == typeof(System.Int32))
                {
                    row[c] = 345435;
                }
                else if (c.DataType == typeof(System.String))
                {
                    row[c] = c.ColumnName + "Value";
                }
                else if (c.DataType == typeof(System.DateTime))
                {
                    row[c] = DateTime.Now;
                }
                else if (c.DataType == typeof(MyStruct))
                {
                    row[c] = new MyStruct()
                    {
                        MyEnum = Day.A4, MyInt32 = 3245, MyString = "wewr"
                    };
                }
                else if (c.DataType == typeof(Day))
                {
                    row[c] = Day.A5;
                }
            }

            EntityTools <DataObjectModel> .FromDataRow(row, obj);

            Assert.AreEqual(obj.Name, "NameValue");

            Trace.Write(Z.Util.XmlTools.ToXml(obj));
        }