Fixed test issue - PEVerify is now called with a quoted assembly path (to allow for...
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy.Tests / AccessLevelTestCase.cs
blob5fb4817552aa174079c9ea337fb20313961169ff
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.DynamicProxy.Tests
17 using System;
18 using System.Collections;
19 using Castle.Core.Interceptor;
20 using Castle.DynamicProxy.Tests.Classes;
21 using Castle.DynamicProxy.Tests.Interceptors;
22 using NUnit.Framework;
24 [TestFixture]
25 public class AccessLevelTestCase : BasePEVerifyTestCase
27 [Test]
28 public void ProtectedConstructor()
30 NonPublicConstructorClass proxy =
31 generator.CreateClassProxy(
32 typeof(NonPublicConstructorClass), new StandardInterceptor())
33 as NonPublicConstructorClass;
35 Assert.IsNotNull(proxy);
37 proxy.DoSomething();
40 [Test]
41 public void ProtectedInternalConstructor ()
43 ProtectedInternalConstructorClass proxy =
44 generator.CreateClassProxy (
45 typeof (ProtectedInternalConstructorClass), new StandardInterceptor())
46 as ProtectedInternalConstructorClass;
48 Assert.IsNotNull (proxy);
50 proxy.DoSomething();
53 [Test]
54 public void ProtectedMethods()
56 LogInvocationInterceptor logger = new LogInvocationInterceptor();
58 NonPublicMethodsClass proxy = (NonPublicMethodsClass)
59 generator.CreateClassProxy(typeof(NonPublicMethodsClass), logger);
61 proxy.DoSomething();
63 Assert.AreEqual(2, logger.Invocations.Count);
64 Assert.AreEqual("DoSomething", logger.Invocations[0]);
65 Assert.AreEqual("DoOtherThing", logger.Invocations[1]);
68 [Test]
69 public void InternalConstructorIsNotReplicated()
71 object proxy = generator.CreateClassProxy(typeof(Hashtable), new StandardInterceptor());
72 Assert.IsNull(proxy.GetType().GetConstructor(new Type[] {typeof(IInterceptor[]), typeof(bool)}));
75 internal class InternalClass
77 internal InternalClass()
82 #if !MONO
84 [Test]
85 public void InternalConstructorIsReplicatedWhenInternalsVisibleTo()
87 object proxy = generator.CreateClassProxy(typeof(InternalClass), new StandardInterceptor());
88 Assert.IsNotNull(proxy.GetType().GetConstructor(new Type[] {typeof(IInterceptor[])}));
91 #endif