From cd6d1f1bbce4234e799d4e218219607c38c0ad8b Mon Sep 17 00:00:00 2001 From: Peter Ibbotson Date: Tue, 10 Sep 2019 15:23:35 +0100 Subject: [PATCH] Added hacky test to show timeout issue --- .../Tcp/NetTcpBindingTests_DelayedMethod.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/Tcp/NetTcpBindingTests_DelayedMethod.cs diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Tcp/NetTcpBindingTests_DelayedMethod.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Tcp/NetTcpBindingTests_DelayedMethod.cs new file mode 100644 index 0000000000..c99c326695 --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Tcp/NetTcpBindingTests_DelayedMethod.cs @@ -0,0 +1,46 @@ +using System; +using Infrastructure.Common; +using System.ServiceModel; +using Xunit; + +public partial class Binding_Tcp_NetTcpBindingTests : ConditionalWcfTest +{ + // Simple echo of a string using NetTcpBinding on both client and server with all default settings. + // Default settings are: + // - SecurityMode = Transport + // - ClientCredentialType = Windows + [WcfFact] + [Condition(nameof(Windows_Authentication_Available))] + [OuterLoop] + public static void DefaultSettings_Echo_DelayedMethod() + { + string testString = "Hello"; + ChannelFactory factory = null; + IWcfService serviceProxy = null; + + try + { + // *** SETUP *** \\ + NetTcpBinding binding = new NetTcpBinding(); + binding.OpenTimeout = TimeSpan.FromMilliseconds(500); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.Tcp_DefaultBinding_Address)); + serviceProxy = factory.CreateChannel(); + ((ICommunicationObject)serviceProxy).Open(); + System.Threading.Thread.Sleep(1000); + // *** EXECUTE *** \\ + string result = serviceProxy.Echo(testString); + + // *** VALIDATE *** \\ + Assert.Equal(testString, result); + + // *** CLEANUP *** \\ + ((ICommunicationObject)serviceProxy).Close(); + factory.Close(); + } + finally + { + // *** ENSURE CLEANUP *** \\ + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); + } + } +}