public void SendDataChunk() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); (var aAssoc, var bAssoc) = AssociationTestHelper.GetConnectedAssociations(logger, 1400); string message = "hello world"; var tcs = new TaskCompletionSource <string>(TaskCreationOptions.RunContinuationsAsynchronously); bAssoc.OnData += (frame) => tcs.TrySetResult(Encoding.UTF8.GetString(frame.UserData)); aAssoc.SendData(0, 0, Encoding.UTF8.GetBytes(message)); tcs.Task.Wait(3000); Assert.True(tcs.Task.IsCompleted); Assert.Equal(message, tcs.Task.Result); }
public void SendLargeFragmentedDataChunk() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); // Setting a very small MTU to force the sending association to use fragmented data chunks. (var aAssoc, var bAssoc) = AssociationTestHelper.GetConnectedAssociations(logger, 1400); byte[] dummyData = new byte[SctpAssociation.DEFAULT_ADVERTISED_RECEIVE_WINDOW]; Crypto.GetRandomBytes(dummyData); string sha256Hash = Crypto.GetSHA256Hash(dummyData); var tcs = new TaskCompletionSource <string>(TaskCreationOptions.RunContinuationsAsynchronously); bAssoc.OnData += (frame) => tcs.TrySetResult(Crypto.GetSHA256Hash(frame.UserData)); aAssoc.SendData(0, 0, dummyData); tcs.Task.Wait(3000); Assert.True(tcs.Task.IsCompleted); Assert.Equal(sha256Hash, tcs.Task.Result); }