Support multiple service models for a component. WindsorServiceHostFactory will...
[castle.git] / Facilities / Remoting / Castle.Facilities.Remoting.Tests / RemoteGenericComponentTestCase.cs
blob294d3422680f0c57e3cd3de250952fc91508aa6e
1 // Copyright 2004-2008 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.
16 namespace Castle.Facilities.Remoting.Tests
18 using System;
19 using System.Text;
20 using System.Runtime.Remoting;
22 using Castle.Windsor;
24 using Castle.Facilities.Remoting.TestComponents;
26 using NUnit.Framework;
28 [TestFixture, Serializable]
29 public class RemoteGenericComponentTestCase : AbstractRemoteTestCase
31 protected override String GetServerConfigFile()
33 return BuildConfigPath("server_kernelgenericcomponent.xml");
36 [Test]
37 public void ClientContainerConsumingRemoteGenericComponent()
39 clientDomain.DoCallBack(new CrossAppDomainDelegate(ClientContainerConsumingRemoteGenericComponentCallback));
42 public void ClientContainerConsumingRemoteGenericComponentCallback()
44 IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, BuildConfigPath("client_kernelgenericcomponent.xml"));
46 IGenericToStringService<String> service = clientContainer.Resolve<IGenericToStringService<String>>();
48 Assert.IsTrue( RemotingServices.IsTransparentProxy(service) );
49 Assert.IsTrue( RemotingServices.IsObjectOutOfAppDomain(service) );
51 Assert.AreEqual("onetwo", service.ToString("one", "two"));
54 [Test]
55 [ExpectedException(typeof(Castle.MicroKernel.ComponentNotFoundException))]
56 public void ClientContainerConsumingRemoteGenericComponentWhichDoesNotExistOnServer()
58 clientDomain.DoCallBack(new CrossAppDomainDelegate(ClientContainerConsumingRemoteGenericComponentWhichDoesNotExistOnServerCallback));
61 public void ClientContainerConsumingRemoteGenericComponentWhichDoesNotExistOnServerCallback()
63 IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, BuildConfigPath("client_kernelgenericcomponent.xml"));
65 GenericToStringServiceImpl<String> service = clientContainer.Resolve<GenericToStringServiceImpl<String>>();
69 [Test]
70 public void ClientContainerConsumingRemoteCustomComponentUsingGenericInterface()
72 clientDomain.DoCallBack(new CrossAppDomainDelegate(ClientContainerConsumingRemoteCustomComponentUsingGenericInterfaceCallback));
75 public void ClientContainerConsumingRemoteCustomComponentUsingGenericInterfaceCallback()
77 IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, BuildConfigPath("client_kernelgenericcomponent.xml"));
80 IGenericToStringService<StringBuilder> service = clientContainer.Resolve<IGenericToStringService<StringBuilder>>();
82 Assert.IsTrue(RemotingServices.IsTransparentProxy(service));
83 Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service));
85 Assert.AreEqual("33", service.ToString(new StringBuilder("one"), new StringBuilder("two")));