Applied Patrick Earl's patch, adding event ModelCreated that allows to re-configure...
[castle.git] / Facilities / Remoting / Castle.Facilities.Remoting.Tests / RemoteSingletonTestCase.cs
blobd65fbb47115806578cc7f1b3125d6a6e4d174a4e
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.Facilities.Remoting.Tests
17 using System;
18 using System.Runtime.Remoting;
20 using Castle.Windsor;
21 using Castle.Facilities.Remoting.TestComponents;
23 using NUnit.Framework;
26 [TestFixture, Serializable]
27 public class RemoteSingletonTestCase : AbstractRemoteTestCase
29 protected override String GetServerConfigFile()
31 return BuildConfigPath("server_simple_scenario.xml");
34 [Test]
35 public void CommonAppConsumingRemoteComponents()
37 clientDomain.DoCallBack(new CrossAppDomainDelegate(CommonAppConsumingRemoteComponentsCallback));
40 public void CommonAppConsumingRemoteComponentsCallback()
42 ICalcService service = (ICalcService)
43 Activator.GetObject( typeof(ICalcService), "tcp://localhost:2133/calcservice" );
45 Assert.IsTrue( RemotingServices.IsTransparentProxy( service ) );
46 Assert.IsTrue( RemotingServices.IsObjectOutOfAppDomain(service) );
48 Assert.AreEqual(10, service.Sum(7,3));
51 [Test]
52 public void ClientContainerConsumingRemoteComponent()
54 clientDomain.DoCallBack(new CrossAppDomainDelegate(ClientContainerConsumingRemoteComponentCallback));
57 public void ClientContainerConsumingRemoteComponentCallback()
59 IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, BuildConfigPath("client_simple_scenario.xml"));
61 ICalcService service = (ICalcService) clientContainer[ typeof(ICalcService) ];
63 Assert.IsTrue( RemotingServices.IsTransparentProxy(service) );
64 Assert.IsTrue( RemotingServices.IsObjectOutOfAppDomain(service) );
66 Assert.AreEqual(10, service.Sum(7,3));
69 [Test]
70 public void WiringRemoteComponent()
72 clientDomain.DoCallBack(new CrossAppDomainDelegate(WiringRemoteComponentCallback));
75 public void WiringRemoteComponentCallback()
77 IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, BuildConfigPath("client_simple_scenario.xml"));
79 clientContainer.AddComponent("comp", typeof(ConsumerComp));
81 ConsumerComp service = (ConsumerComp) clientContainer[ typeof(ConsumerComp) ];
83 Assert.IsNotNull( service.Calcservice );
84 Assert.IsTrue( RemotingServices.IsTransparentProxy(service.Calcservice) );
85 Assert.IsTrue( RemotingServices.IsObjectOutOfAppDomain(service.Calcservice) );