forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the Close method. (dotnet#2577)
Expose the Close method on ClientBase<TChannel>
- Loading branch information
1 parent
2f78dd0
commit ab08229
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/System.ServiceModel.Primitives/tests/ServiceModel/ClientBaseTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Description; | ||
using System.ServiceModel.Channels; | ||
using System.Text; | ||
using Infrastructure.Common; | ||
using Xunit; | ||
|
||
public static class ClientBaseTest | ||
{ | ||
[WcfTheory] | ||
public static void ClientBaseCloseMethodClosesCorrectly() | ||
{ | ||
// *** SETUP *** \\ | ||
BasicHttpBinding binding = new BasicHttpBinding(); | ||
MyClientBase client = new MyClientBase(binding, new EndpointAddress("http://myendpoint")); | ||
|
||
// *** VALIDATE *** \\ | ||
Assert.Equal(CommunicationState.Created, client.State); | ||
client.Open(); | ||
Assert.Equal(CommunicationState.Opened, client.State); | ||
client.Close(); | ||
Assert.Equal(CommunicationState.Closed, client.State); | ||
} | ||
|
||
public class MyClientBase : ClientBase<ITestService> | ||
{ | ||
public MyClientBase(Binding binding, EndpointAddress endpointAddress) | ||
: base(binding, endpointAddress) | ||
{ | ||
} | ||
|
||
public ITestService Proxy | ||
{ | ||
get { return base.Channel; } | ||
} | ||
} | ||
|
||
[ServiceContract] | ||
public interface ITestService | ||
{ | ||
[OperationContract] | ||
string Echo(string message); | ||
} | ||
} |