0
|
1 using System;
|
|
2 using System.Runtime.CompilerServices;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 using BLToolkit.Reflection;
|
|
7 using BLToolkit.TypeBuilder;
|
|
8
|
|
9 [assembly: InternalsVisibleTo("InternalTypesTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001001d9a12fa5826334c27adac46b64048c08dc48a37113586f0b315baefeecad081ce1d907ef8879ea1dcea6decb9f0d87840ff60fc5bd2a3919469284481b6ae7b73ebb327503cd16c9ecd95b6ed9decc80116dfbe680dc1ad83c5aa89af3e48f5f9f94444901168e58a782f0831d88f6e00f47cd9eb209c40064fb5b002ef79be")]
|
|
10
|
|
11 namespace TypeBuilder
|
|
12 {
|
|
13 [TestFixture]
|
|
14 public class InternalTypesTest
|
|
15 {
|
|
16 internal abstract class InternalObject
|
|
17 {
|
|
18 public abstract string PublicValue { get; set; }
|
|
19 }
|
|
20
|
|
21 public abstract class PublicObject
|
|
22 {
|
|
23 internal string InternalField;
|
|
24 internal abstract string InternalValue { get; set; }
|
|
25 internal protected abstract string ProtectedInternalValue { get; set; }
|
|
26 public abstract string PublicValue { get; internal set; }
|
|
27 public string NonAbstractValue
|
|
28 {
|
|
29 get { return InternalField; }
|
|
30 internal set { InternalField = value; }
|
|
31 }
|
|
32 }
|
|
33
|
|
34 [Test]
|
|
35 public void Test()
|
|
36 {
|
|
37 TypeFactory.SetGlobalAssembly("InternalTypesTest.dll", new Version(1,2,3,4), "TypeBuilder/InternalTypesTest.snk");
|
|
38
|
|
39 var o = TypeAccessor.CreateInstance<InternalObject>();
|
|
40 Assert.IsNotNull(o);
|
|
41
|
|
42 var o2 = TypeAccessor.CreateInstance<PublicObject>();
|
|
43 Assert.IsNotNull(o2);
|
|
44
|
|
45 TypeFactory.SaveGlobalAssembly();
|
|
46
|
|
47 var ta = TypeAccessor<PublicObject>.Instance;
|
|
48
|
|
49 Assert.IsNotNull(ta["InternalField"]);
|
|
50 Assert.IsTrue (ta["InternalField"].HasGetter);
|
|
51 Assert.IsTrue (ta["InternalField"].HasSetter);
|
|
52 Assert.IsNotNull(ta["PublicValue"]);
|
|
53 Assert.IsTrue (ta["PublicValue"].HasGetter);
|
|
54 Assert.IsTrue (ta["PublicValue"].HasSetter);
|
|
55 Assert.IsNotNull(ta["InternalValue"]);
|
|
56 Assert.IsTrue (ta["InternalValue"].HasGetter);
|
|
57 Assert.IsTrue (ta["InternalValue"].HasSetter);
|
|
58 Assert.IsNotNull(ta["ProtectedInternalValue"]);
|
|
59 Assert.IsTrue (ta["ProtectedInternalValue"].HasGetter);
|
|
60 Assert.IsTrue (ta["ProtectedInternalValue"].HasSetter);
|
|
61 Assert.IsNotNull(ta["NonAbstractValue"]);
|
|
62 Assert.IsTrue (ta["NonAbstractValue"].HasGetter);
|
|
63 Assert.IsTrue (ta["NonAbstractValue"].HasSetter);
|
|
64 }
|
|
65 }
|
|
66 }
|