Unittests for issue #283

These unittests fail intentionally as the issue discussion has not reached
a consesual solution. Any solution should pass the unittests added in this commit.
This commit is contained in:
Jakob Ledermann
2020-08-18 17:27:12 +02:00
committed by Serge Camille
parent c79ae13ea1
commit 7d570f93c1

View File

@@ -34,6 +34,33 @@ namespace S7.Net.UnitTest
var t = TPKT.Read(m);
}
[TestMethod]
public async Task TPKT_ReadDelayedAsync()
{
var fullMessage = ProtocolUnitTest.StringToByteArray("0300002902f0803203000000010002001400000401ff0400807710000100000103000000033f8ccccd");
var m = new MemoryStream();
m.Write(fullMessage, 0, 2);
var tcs = new TaskCompletionSource<bool>();
tcs.Task.ContinueWith(x => m.Write(fullMessage, 2, fullMessage.Length - 2));
var t = TPKT.ReadAsync(m);
tcs.TrySetResult(true);
await t;
}
[TestMethod]
public void TPKT_ReadDelayed()
{
var fullMessage = ProtocolUnitTest.StringToByteArray("0300002902f0803203000000010002001400000401ff0400807710000100000103000000033f8ccccd");
var m = new MemoryStream();
m.Write(fullMessage, 0, 2);
var tcs = new TaskCompletionSource<bool>();
tcs.Task.ContinueWith(x => m.Write(fullMessage, 2, fullMessage.Length - 2));
Task.Delay(TimeSpan.FromSeconds(0.01)).ContinueWith(x => tcs.TrySetResult(true));
var t = TPKT.Read(m);
tcs.TrySetResult(true);
}
[TestMethod]
[ExpectedException(typeof(TPKTInvalidException))]
public async Task TPKT_ReadShortAsync()