comparison UnitTests/Fluent/FluentMapAttributesTest.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.Collections.Generic;
2
3 using BLToolkit.Data;
4 using BLToolkit.Mapping.Fluent;
5 using BLToolkit.Mapping.MemberMappers;
6 using BLToolkit.Reflection.Extension;
7 using Microsoft.VisualStudio.TestTools.UnitTesting;
8
9 namespace BLToolkit.Fluent.Test
10 {
11 /// <summary>
12 /// Test for FluentConfig
13 /// </summary>
14 [TestClass]
15 public class FluentMapAttributesTest
16 {
17 /// <summary>
18 /// Test configure mapping
19 /// </summary>
20 [TestMethod]
21 public void ShouldConfigMapping()
22 {
23 ExtensionList extensions = new ExtensionList();
24 FluentConfig.Configure(extensions).MapingFromAssemblyOf<FluentMapAttributesTest>();
25
26 var key = extensions[typeof(DboFluentMapAttributesTest).FullName];
27 var mem1 = key["Id"];
28 Assert.IsTrue(mem1.Attributes.ContainsKey("Identity"));
29
30 var mem2 = key["Test"];
31 Assert.IsTrue(mem2.Attributes.ContainsKey("MemberMapper"));
32 Assert.IsTrue(mem2.Attributes.ContainsKey("DbType"));
33 }
34
35 public class DboFluentMapAttributesTest
36 {
37 public int Id { get; set; }
38 public List<string> Test { get; set; }
39 }
40
41 public class DboFluentMapAttributesTestMap : FluentMap<DboFluentMapAttributesTest>
42 {
43 public DboFluentMapAttributesTestMap()
44 {
45 TableName("t1");
46
47 MapField(x => x.Id).Identity();
48 MapField(x => x.Test).MapIgnore(false).MemberMapper(typeof(BinarySerialisationMapper)).DbType(System.Data.DbType.Binary);
49 }
50 }
51
52 }
53 }