Merge pull request #400 from scamille/tests-taskCanceled

Fix Cancellation test.
This commit is contained in:
Michael Croes
2021-06-07 22:03:02 +02:00
committed by GitHub

View File

@@ -935,15 +935,15 @@ namespace S7.Net.UnitTest
{
await plc.WriteBytesAsync(DataType.DataBlock, db, 0, data, cancellationToken);
}
catch(TaskCanceledException)
catch(OperationCanceledException)
{
// everything is good, that is the exception we expect
Console.WriteLine("Task was cancelled as expected.");
Console.WriteLine("Operation was cancelled as expected.");
return;
}
catch(Exception e)
{
Assert.Fail($"Wrong exception type received. Expected {typeof(TaskCanceledException)}, received {e.GetType()}.");
Assert.Fail($"Wrong exception type received. Expected {typeof(OperationCanceledException)}, received {e.GetType()}.");
}
// Depending on how tests run, this can also just succeed without getting cancelled at all. Do nothing in this case.