comparison HowTo/DataAccess/ActualType.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 NUnit.Framework;
4
5 using BLToolkit.DataAccess;
6
7 namespace HowTo.DataAccess
8 {
9 [TestFixture]
10 public class ActualType
11 {
12 public interface IName
13 {
14 string Name { get; }
15 }
16
17 public class NameBase : IName
18 {
19 private string _name;
20 public string Name { get { return _name; } set { _name = value; } }
21 }
22
23 public class Name1 : NameBase {}
24 public class Name2 : NameBase {}
25
26 [/*[a]*/ActualType/*[/a]*/(typeof(IName), typeof(/*[a]*/Name1/*[/a]*/))]
27 public abstract class TestAccessor : DataAccessor
28 {
29 [SqlQuery("SELECT 'John' as Name")]
30 public abstract IName GetName1();
31
32 [SqlQuery("SELECT 'John' as Name"), /*[a]*/ObjectType/*[/a]*/(typeof(/*[a]*/Name2/*[/a]*/))]
33 public abstract IName GetName2();
34
35 [SqlQuery("SELECT 'John' as Name")]
36 public abstract IList<IName> GetName1List();
37
38 [SqlQuery("SELECT 'John' as Name"), /*[a]*/ObjectType/*[/a]*/(typeof(/*[a]*/Name2/*[/a]*/))]
39 public abstract IList<IName> GetName2List();
40
41 [SqlQuery("SELECT 1 as ID, 'John' as Name"), Index("@ID")]
42 public abstract IDictionary<int, IName> GetName1Dictionary();
43
44 [SqlQuery("SELECT 1 as ID, 'John' as Name"), Index("@ID"), /*[a]*/ObjectType/*[/a]*/(typeof(/*[a]*/Name2/*[/a]*/))]
45 public abstract IDictionary<int, IName> GetName2Dictionary();
46 }
47
48 [Test]
49 public void Test()
50 {
51 TestAccessor ta = DataAccessor.CreateInstance<TestAccessor>();
52
53 Assert.IsTrue(ta.GetName1() is Name1);
54 Assert.IsTrue(ta.GetName2() is Name2);
55 Assert.IsTrue(ta.GetName1List()[0] is Name1);
56 Assert.IsTrue(ta.GetName2List()[0] is Name2);
57 Assert.IsTrue(ta.GetName1Dictionary()[1] is Name1);
58 Assert.IsTrue(ta.GetName2Dictionary()[1] is Name2);
59 }
60 }
61 }