0
|
1 using System;
|
|
2
|
|
3 using NUnit.Framework;
|
|
4
|
|
5 using BLToolkit.DataAccess;
|
|
6 using BLToolkit.Mapping;
|
|
7 using BLToolkit.Reflection.Extension;
|
|
8 using BLToolkit.Data;
|
|
9
|
|
10 namespace DataAccess
|
|
11 {
|
|
12 [TestFixture]
|
|
13 public class XmlExtension
|
|
14 {
|
|
15 public class Person1
|
|
16 {
|
|
17 [MapField("PersonID")] public int ID;
|
|
18 [MapField("FirstName")] public string Name;
|
|
19 }
|
|
20
|
|
21 [Test]
|
|
22 public void Test()
|
|
23 {
|
|
24 using (DbManager db = new DbManager())
|
|
25 {
|
|
26 SqlQuery sq = new SqlQuery(db);
|
|
27 sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml");
|
|
28 Assert.IsNotNull(sq.Extensions["Person1"]);
|
|
29
|
|
30 Person1 ps = (Person1)sq.SelectByKey(typeof(Person1), 1);
|
|
31 Assert.IsNotNull(ps);
|
|
32 }
|
|
33 }
|
|
34
|
|
35 [Test]
|
|
36 public void GenericsTest()
|
|
37 {
|
|
38 using (DbManager db = new DbManager())
|
|
39 {
|
|
40 SqlQuery<Person1> sq = new SqlQuery<Person1>(db);
|
|
41 sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml");
|
|
42 Assert.IsNotNull(sq.Extensions["Person1"]);
|
|
43
|
|
44 Person1 ps = sq.SelectByKey(1);
|
|
45 Assert.IsNotNull(ps);
|
|
46 }
|
|
47 }
|
|
48 }
|
|
49 }
|
|
50
|