comparison UnitTests/CS/Mapping/XmlMap.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
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 }