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
.Facilities
.WcfIntegration
.Tests
18 using System
.ServiceModel
;
20 using Castle
.MicroKernel
.Registration
;
22 using Castle
.Facilities
.WcfIntegration
.Demo
;
23 using NUnit
.Framework
;
26 public class WcfClientFixture
28 #region Setup/Teardown
31 public void TestInitialize()
33 windsorContainer
= new WindsorContainer()
34 .AddFacility("wcf_facility", new WcfFacility())
36 Component
.For
<IOperations
>().ImplementedBy
<Operations
>()
37 .CustomDependencies(new
40 serviceModel
= new WcfServiceModel()
41 .AddEndpoints(new WcfEndpoint()
43 Binding
= new NetTcpBinding(),
44 Address
= "net.tcp://localhost/Operations"
47 Component
.For
<IAmUsingWindsor
>().ImplementedBy
<UsingWindsor
>()
48 .CustomDependencies(new
51 serviceModel
= new WcfServiceModel()
57 public void TestCleanup()
59 windsorContainer
.Dispose();
64 private IWindsorContainer windsorContainer
;
67 public void CanResolveClientAssociatedWithChannel()
69 windsorContainer
.Register(
70 Component
.For
<IOperations
>()
72 .CustomDependencies(new
74 clientModel
= new WcfClientModel()
76 Binding
= new NetTcpBinding(),
77 Address
= "net.tcp://localhost/Operations"
82 IOperations client
= windsorContainer
.Resolve
<IOperations
>("operations");
83 Assert
.AreEqual(42, client
.GetValueFromConstructor());
87 public void CanResolveClientAssociatedWithChannelFromConfiguration()
89 windsorContainer
.Register(Component
.For
<IAmUsingWindsor
>()
90 .Named("usingWindsor")
91 .CustomDependencies(new
93 clientModel
= new WcfClientModel("WSHttpBinding_IAmUsingWindsor")
96 IAmUsingWindsor client
= windsorContainer
.Resolve
<IAmUsingWindsor
>("usingWindsor");
97 Assert
.AreEqual(42, client
.GetValueFromWindsorConfig());