Write large byte array in S7NetTests to check for MaxPDU problems on Snap7.

For me the tests work fine even when adjust the "chunk size" in WriteBytesAsync. So Snap7 seems to be fine, at least the current version.

This should probably be tested with some live PLC's as well.
This commit is contained in:
Serge Camille
2020-08-17 22:30:37 +02:00
parent 783c456dc9
commit 2bb7ac7d2a
2 changed files with 40 additions and 0 deletions

View File

@@ -128,6 +128,26 @@ namespace S7.Net.UnitTest
Assert.AreEqual(val3, result3);
}
/// <summary>
/// Write/Read a large amount of data to test PDU max
/// </summary>
[TestMethod]
public async Task Test_Async_WriteLargeByteArray()
{
Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor.");
var randomEngine = new Random();
var data = new byte[8192];
var db = 2;
randomEngine.NextBytes(data);
await plc.WriteBytesAsync(DataType.DataBlock, db, 0, data);
var readData = await plc.ReadBytesAsync(DataType.DataBlock, db, 0, data.Length);
CollectionAssert.AreEqual(data, readData);
}
/// <summary>
/// Read/Write a class that has the same properties of a DB with the same field in the same order
/// </summary>