Skip to content

Commit

Permalink
Expose the Close method. (#2577)
Browse files Browse the repository at this point in the history
Expose the Close method on ClientBase<TChannel>
  • Loading branch information
StephenBonikowsky authored and zhenlan committed Feb 21, 2018
1 parent 2f78dd0 commit ab08229
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ event System.EventHandler System.ServiceModel.ICommunicationObject.Faulted { add
event System.EventHandler System.ServiceModel.ICommunicationObject.Opened { add { } remove { } }
event System.EventHandler System.ServiceModel.ICommunicationObject.Opening { add { } remove { } }
public void Abort() { }
public void Close() { }
protected virtual TChannel CreateChannel() { return default(TChannel); }
protected T GetDefaultValueForInitialization<T>() { return default(T); }
protected void InvokeAsync(System.ServiceModel.ClientBase<TChannel>.BeginOperationDelegate beginOperationDelegate, object[] inValues, System.ServiceModel.ClientBase<TChannel>.EndOperationDelegate endOperationDelegate, System.Threading.SendOrPostCallback operationCompletedCallback, object userState) { }
Expand Down
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);
}
}

0 comments on commit ab08229

Please sign in to comment.