0
|
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 } |