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
.Rest
18 using System
.ServiceModel
;
19 using Castle
.MicroKernel
.Registration
;
21 using Castle
.Facilities
.WcfIntegration
.Rest
;
22 using NUnit
.Framework
;
27 public class RestClientFixture
29 #region Setup/Teardown
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"))
44 public void TestCleanup()
46 windsorContainer
.Dispose();
51 private IWindsorContainer windsorContainer
;
54 public void CanResolveClientAssociatedWithWebChannel()
56 windsorContainer
.Register(
57 Component
.For
<ICalculator
>()
59 .ActAs(new RestClientModel("http://localhost:27198"))
62 ICalculator calculator
= windsorContainer
.Resolve
<ICalculator
>("calculator");
63 Assert
.AreEqual(21, calculator
.Multiply(3, 7));
67 public void CanResolveExplicitClientAssociatedWithWebChannel()
69 windsorContainer
.Register(
70 Component
.For
<ICalculator
>()
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));