diff UnitTests/CS/Reflection/ExtendedPropertyDescriptorTest.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/CS/Reflection/ExtendedPropertyDescriptorTest.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,48 @@
+using System;
+using System.ComponentModel;
+
+using NUnit.Framework;
+
+using BLToolkit.Reflection;
+
+namespace Reflection
+{
+	[TestFixture]
+	public class ExtendedPropertyDescriptorTest
+	{
+		public class RootType
+		{
+			private Type1 _type1 = new Type1();
+			public  Type1  Type1 { get { return _type1; } }
+		}
+
+		public class Type1
+		{
+			private Type2 _type2 = new Type2();
+			public  Type2  Type2 { get { return _type2; } }
+		}
+
+		public class Type2
+		{
+			public string Name
+			{
+				get { return "test";  }
+			}
+		}
+
+		[Test]
+		public void Test()
+		{
+			TypeAccessor ta = TypeAccessor.GetAccessor(typeof(RootType));
+
+			PropertyDescriptorCollection col  = ta.CreateExtendedPropertyDescriptors(null, null);
+			PropertyDescriptor           prop = col["Type1+Type2+Name"];
+
+			RootType obj = new RootType();
+
+			object value = prop.GetValue(obj);
+
+			Assert.AreEqual("test", value);
+		}
+	}
+}