Some cleanup and initial RESTful support.
[castle.git] / Facilities / Wcf / Castle.Facilities.WcfIntegration.Tests / Rest / RestClientFixture.cs
blob643a75e593211297c871ceda6b94076fed0e9c64
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.Rest
17 using System;
18 using System.ServiceModel;
19 using Castle.MicroKernel.Registration;
20 using Castle.Windsor;
21 using Castle.Facilities.WcfIntegration.Rest;
22 using NUnit.Framework;
24 #if DOTNET35
26 [TestFixture]
27 public class RestClientFixture
29 #region Setup/Teardown
31 [SetUp]
32 public void TestInitialize()
34 windsorContainer = new WindsorContainer()
35 .AddFacility<WcfFacility>()
36 .Register(Component.For<ICalculator>()
37 .ImplementedBy<Calculator>()
38 .DependsOn(new { number = 42 })
39 .ActAs(new RestServiceModel("http://localhost:27198"))
43 [TearDown]
44 public void TestCleanup()
46 windsorContainer.Dispose();
49 #endregion
51 private IWindsorContainer windsorContainer;
53 [Test]
54 public void CanResolveClientAssociatedWithWebChannel()
56 windsorContainer.Register(
57 Component.For<ICalculator>()
58 .Named("calculator")
59 .ActAs(new RestClientModel("http://localhost:27198"))
62 ICalculator calculator = windsorContainer.Resolve<ICalculator>("calculator");
63 Assert.AreEqual(21, calculator.Multiply(3, 7));
66 [Test]
67 public void CanResolveExplicitClientAssociatedWithWebChannel()
69 windsorContainer.Register(
70 Component.For<ICalculator>()
71 .Named("calculator")
72 .ActAs(new RestClientModel()
74 Endpoint = WcfEndpoint
75 .BoundTo(new WebHttpBinding())
76 .At("http://localhost:27198")
80 ICalculator calculator = windsorContainer.Resolve<ICalculator>("calculator");
81 Assert.AreEqual(75, calculator.Subtract(100, 25));
84 #endif // DOTNET35