1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
;
23 public class SmartProxyTestCase
25 private IWindsorContainer _container
;
27 public SmartProxyTestCase()
34 _container
= new WindsorContainer();
36 _container
.AddFacility("1", new MyInterceptorGreedyFacility());
37 _container
.AddFacility("2", new MyInterceptorGreedyFacility());
38 _container
.AddFacility("3", new MyInterceptorGreedyFacility());
42 public void Terminate()
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
);
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));
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));