Missed the test project.
[castle.git] / Facilities / Wcf / Castle.Facilities.WcfIntegration.Tests / WcfClientFixture.cs
blob8073c81fa8c127a759d660366c829989ccb2490e
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.
15 namespace Castle.Facilities.WcfIntegration.Tests
17 using System;
18 using System.ServiceModel;
19 using Castle.Core;
20 using Castle.MicroKernel.Registration;
21 using Castle.Windsor;
22 using Castle.Facilities.WcfIntegration.Demo;
23 using NUnit.Framework;
25 [TestFixture]
26 public class WcfClientFixture
28 #region Setup/Teardown
30 [SetUp]
31 public void TestInitialize()
33 windsorContainer = new WindsorContainer()
34 .AddFacility("wcf_facility", new WcfFacility())
35 .Register(
36 Component.For<IOperations>().ImplementedBy<Operations>()
37 .CustomDependencies(new
39 number = 42,
40 serviceModel = new WcfServiceModel()
41 .AddEndpoints(new WcfEndpoint()
43 Binding = new NetTcpBinding(),
44 Address = "net.tcp://localhost/Operations"
46 }),
47 Component.For<IAmUsingWindsor>().ImplementedBy<UsingWindsor>()
48 .CustomDependencies(new
50 number = 42,
51 serviceModel = new WcfServiceModel()
56 [TearDown]
57 public void TestCleanup()
59 windsorContainer.Dispose();
62 #endregion
64 private IWindsorContainer windsorContainer;
66 [Test]
67 public void CanResolveClientAssociatedWithChannel()
69 windsorContainer.Register(
70 Component.For<IOperations>()
71 .Named("operations")
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());
86 [Test]
87 public void CanResolveClientAssociatedWithChannelFromConfiguration()
89 windsorContainer.Register(Component.For<IAmUsingWindsor>()
90 .Named("usingWindsor")
91 .CustomDependencies(new
93 clientModel = new WcfClientModel("WSHttpBinding_IAmUsingWindsor")
94 }));
96 IAmUsingWindsor client = windsorContainer.Resolve<IAmUsingWindsor>("usingWindsor");
97 Assert.AreEqual(42, client.GetValueFromWindsorConfig());