0
|
1 using System;
|
|
2 using System.ComponentModel;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 using BLToolkit.Reflection;
|
|
7
|
|
8 namespace Reflection
|
|
9 {
|
|
10 [TestFixture]
|
|
11 public class ExtendedPropertyDescriptorTest
|
|
12 {
|
|
13 public class RootType
|
|
14 {
|
|
15 private Type1 _type1 = new Type1();
|
|
16 public Type1 Type1 { get { return _type1; } }
|
|
17 }
|
|
18
|
|
19 public class Type1
|
|
20 {
|
|
21 private Type2 _type2 = new Type2();
|
|
22 public Type2 Type2 { get { return _type2; } }
|
|
23 }
|
|
24
|
|
25 public class Type2
|
|
26 {
|
|
27 public string Name
|
|
28 {
|
|
29 get { return "test"; }
|
|
30 }
|
|
31 }
|
|
32
|
|
33 [Test]
|
|
34 public void Test()
|
|
35 {
|
|
36 TypeAccessor ta = TypeAccessor.GetAccessor(typeof(RootType));
|
|
37
|
|
38 PropertyDescriptorCollection col = ta.CreateExtendedPropertyDescriptors(null, null);
|
|
39 PropertyDescriptor prop = col["Type1+Type2+Name"];
|
|
40
|
|
41 RootType obj = new RootType();
|
|
42
|
|
43 object value = prop.GetValue(obj);
|
|
44
|
|
45 Assert.AreEqual("test", value);
|
|
46 }
|
|
47 }
|
|
48 }
|