mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
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:
committed by
Serge Camille
parent
c79ae13ea1
commit
7d570f93c1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user