0
|
1 using System;
|
|
2 using System.Data;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 using BLToolkit.DataAccess;
|
|
7 using BLToolkit.Mapping;
|
|
8 using BLToolkit.Reflection.Extension;
|
|
9
|
|
10 namespace Mapping
|
|
11 {
|
|
12 [TestFixture]
|
|
13 public class XmlMap
|
|
14 {
|
|
15 public class Person
|
|
16 {
|
|
17 [PrimaryKey]
|
|
18 [MapField("PersonID")] public int ID;
|
|
19 [MapField("FirstName")] public string FName;
|
|
20 [MapField("LastName")] public string LName;
|
|
21 }
|
|
22
|
|
23 [Test]
|
|
24 public void Test()
|
|
25 {
|
|
26 Person p = (Person)new SqlQuery().SelectByKey(typeof(Person), 1);
|
|
27
|
|
28 Assert.AreEqual(1, p.ID);
|
|
29 Assert.AreEqual("John", p.FName);
|
|
30 Assert.AreEqual("Pupkin", p.LName);
|
|
31
|
|
32 MappingSchema map = new MappingSchema();
|
|
33
|
|
34 map.Extensions = TypeExtension.GetExtensions("XmlMap.xml");
|
|
35
|
|
36 DataRow dr = map.MapObjectToDataRow(p, new DataTable());
|
|
37
|
|
38 Assert.AreEqual(1, dr["PERSON_ID"]);
|
|
39 Assert.AreEqual("John", dr["FIRST_NAME"]);
|
|
40 Assert.AreEqual("Pupkin", dr["LAST_NAME"]);
|
|
41 }
|
|
42 }
|
|
43 }
|