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.
16 namespace Castle
.Facilities
.Remoting
.Tests
20 using System
.Runtime
.Remoting
;
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");
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"));
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
>>();
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")));