Reverted DictionaryComponentAttribute changes.
[castle.git] / InversionOfControl / Castle.Windsor.Tests / SmartProxyTestCase.cs
blobe0ebb9f6b65945614ec277e20c7489668b747a20
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.Windsor.Tests
17 using System.Runtime.Remoting;
18 using Castle.Core.Interceptor;
19 using Castle.Windsor.Tests.Components;
20 using NUnit.Framework;
22 [TestFixture]
23 public class SmartProxyTestCase
25 private IWindsorContainer _container;
27 public SmartProxyTestCase()
31 [SetUp]
32 public void Init()
34 _container = new WindsorContainer();
36 _container.AddFacility("1", new MyInterceptorGreedyFacility());
37 _container.AddFacility("2", new MyInterceptorGreedyFacility());
38 _container.AddFacility("3", new MyInterceptorGreedyFacility());
41 [TearDown]
42 public void Terminate()
44 _container.Dispose();
47 [Test]
48 public void InterfaceInheritance()
50 _container.AddComponent("interceptor", typeof(StandardInterceptor));
51 _container.AddComponent("key", typeof(ICameraService), typeof(CameraService));
53 ICameraService service = (ICameraService) _container.Resolve("key");
55 Assert.IsNotNull(service);
58 [Test]
59 public void InterfaceProxy()
61 _container.AddComponent("interceptor", typeof(ResultModifierInterceptor));
62 _container.AddComponent("key",
63 typeof(ICalcService), typeof(CalculatorService));
65 ICalcService service = (ICalcService) _container.Resolve("key");
67 Assert.IsNotNull(service);
68 Assert.IsFalse(RemotingServices.IsTransparentProxy(service));
69 Assert.AreEqual(7, service.Sum(2, 2));
72 [Test]
73 public void ConcreteClassProxy()
75 _container.AddComponent("interceptor", typeof(ResultModifierInterceptor));
76 _container.AddComponent("key", typeof(CalculatorService));
78 CalculatorService service = (CalculatorService) _container.Resolve("key");
80 Assert.IsNotNull(service);
81 Assert.IsFalse(RemotingServices.IsTransparentProxy(service));
82 Assert.AreEqual(7, service.Sum(2, 2));