Skip to content

Commit

Permalink
Added hacky test to show timeout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
peteri committed Sep 10, 2019
1 parent a93ad25 commit cd6d1f1
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<IWcfService> factory = null;
IWcfService serviceProxy = null;

try
{
// *** SETUP *** \\
NetTcpBinding binding = new NetTcpBinding();
binding.OpenTimeout = TimeSpan.FromMilliseconds(500);
factory = new ChannelFactory<IWcfService>(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);
}
}
}

0 comments on commit cd6d1f1

Please sign in to comment.