Skip to content

Commit

Permalink
fix bug and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
afifi-ins authored and mconnew committed Aug 7, 2024
1 parent 0246e76 commit af275d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,42 @@ public static void ReceiveTimeout_Applied()
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
}
}

// Test for https://github.com/CoreWCF/CoreWCF/issues/1391
[WcfFact]
[OuterLoop]
public static void SecurityModeNone_Echo_RoundTrips_String_Stream_TimeoutMaxValue()
{
string testString = "Hello";
ChannelFactory<IWcfServiceGenerated> factory = null;
IWcfServiceGenerated serviceProxy = null;

try
{
// *** SETUP *** \\
var binding = new NetTcpBinding(SecurityMode.None)
{
SendTimeout = TimeSpan.MaxValue,
ReceiveTimeout = TimeSpan.MaxValue
};
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
binding.TransferMode = TransferMode.Streamed;

factory = new ChannelFactory<IWcfServiceGenerated>(binding, new EndpointAddress(Endpoints.Tcp_Streamed_NoSecurity_Address));
serviceProxy = factory.CreateChannel();

// *** EXECUTE *** \\
string result = serviceProxy.Echo(testString);
Assert.Equal(testString, result);

// *** CLEANUP *** \\
((ICommunicationObject)serviceProxy).Close();
factory.Close();
}
finally
{
// *** ENSURE CLEANUP *** \\
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ private ValueTask WriteChunkSizeAsync(int size)
if (size > 0)
{
int bytesEncoded = IntEncoder.Encode(size, _encodedSize);
return Connection.WriteAsync(_encodedSize.Slice(0, bytesEncoded), false, TimeSpan.FromMilliseconds(WriteTimeout));
return Connection.WriteAsync(_encodedSize.Slice(0, bytesEncoded), false, TimeoutHelper.FromMilliseconds(WriteTimeout));
}
else
{
Expand Down

0 comments on commit af275d1

Please sign in to comment.