Missed the test project.
[castle.git] / Facilities / Wcf / Castle.Facilities.WcfIntegration.Tests / ServiceHostFixture.cs
blob598c71d147a5b760d2a16cf1d996e22be8aeb076
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.MicroKernel.Registration;
20 using Castle.Windsor;
21 using Castle.Facilities.WcfIntegration.Demo;
22 using NUnit.Framework;
24 [TestFixture]
25 public class ServiceHostFixture
27 [Test]
28 public void CanCreateServiceHost()
30 WindsorServiceHost host = new WindsorServiceHost(new WindsorContainer().Kernel, typeof (Operations));
31 Assert.IsNotNull(host);
34 [Test]
35 public void CanCreateServiceHostAndOpenHost()
37 using (new WindsorContainer()
38 .AddFacility("wcf_facility", new WcfFacility())
39 .Register(Component.For<IOperations>().ImplementedBy<Operations>()
40 .CustomDependencies(new
42 number = 42,
43 serviceModel = new WcfServiceModel()
44 .AddEndpoints(new WcfEndpoint()
46 Binding = new NetTcpBinding(),
47 Address = "net.tcp://localhost/Operations"
52 IOperations client = ChannelFactory<IOperations>.CreateChannel(
53 new NetTcpBinding(), new EndpointAddress("net.tcp://localhost/Operations"));
54 Assert.AreEqual(42, client.GetValueFromConstructor());
58 [Test]
59 public void CanCreateServiceHostAndOpenHostFromConfiguration()
61 using (new WindsorContainer()
62 .AddFacility("wcf_facility", new WcfFacility())
63 .Register(Component.For<UsingWindsor>()
64 .CustomDependencies(new
66 number = 42,
67 serviceModel = new WcfServiceModel()
71 IAmUsingWindsor client = ChannelFactory<IAmUsingWindsor>.CreateChannel(
72 new BasicHttpBinding(), new EndpointAddress("http://localhost:27198/UsingWindsor.svc"));
73 Assert.AreEqual(42, client.GetValueFromWindsorConfig());
77 [Test]
78 public void CanCreateServiceHostAndOpenHostWithMultipleEndpoints()
80 using (new WindsorContainer()
81 .AddFacility("wcf_facility", new WcfFacility())
82 .Register(Component.For<Operations>()
83 .CustomDependencies(new
85 number = 42,
86 serviceModel = new WcfServiceModel()
87 .AddEndpoints(
88 new WcfEndpoint<IOperations>()
90 Binding = new NetTcpBinding(),
91 Address = "net.tcp://localhost/Operations"
93 new WcfEndpoint<IOperationsEx>()
95 Binding = new BasicHttpBinding(),
96 Address = "http://localhost:27198/UsingWindsor.svc"
102 IOperations client = ChannelFactory<IOperations>.CreateChannel(
103 new NetTcpBinding(), new EndpointAddress("net.tcp://localhost/Operations"));
104 Assert.AreEqual(42, client.GetValueFromConstructor());
106 IOperationsEx clientEx = ChannelFactory<IOperationsEx>.CreateChannel(
107 new BasicHttpBinding(), new EndpointAddress("http://localhost:27198/UsingWindsor.svc"));
108 clientEx.Backup();
112 [Test]
113 public void CanCreateServiceHostAndOpenHostWithRelativeEndpoints()
115 using (new WindsorContainer()
116 .AddFacility("wcf_facility", new WcfFacility())
117 .Register(Component.For<Operations>()
118 .CustomDependencies(new
120 number = 42,
121 serviceModel = new WcfServiceModel()
122 .AddBaseAddresses(
123 "net.tcp://localhost/Operations",
124 "http://localhost:27198/UsingWindsor.svc")
125 .AddEndpoints(
126 new WcfEndpoint<IOperations>()
128 Binding = new NetTcpBinding()
130 new WcfEndpoint<IOperationsEx>()
132 Binding = new BasicHttpBinding(),
133 Address = "Extended"
139 IOperations client = ChannelFactory<IOperations>.CreateChannel(
140 new NetTcpBinding(), new EndpointAddress("net.tcp://localhost/Operations"));
141 Assert.AreEqual(42, client.GetValueFromConstructor());
143 IOperationsEx clientEx = ChannelFactory<IOperationsEx>.CreateChannel(
144 new BasicHttpBinding(), new EndpointAddress("http://localhost:27198/UsingWindsor.svc/Extended"));
145 clientEx.Backup();