public void EncryptionCancellationTestAsync()
{
var cancellationTokenSource = new CancellationTokenSource();
var progressEncrypt = new Progress<StreamCryptorTaskAsyncProgress>();
progressEncrypt.ProgressChanged +=
(s, e) =>
{
if (e.ProgressPercentage > 10)
{
cancellationTokenSource.Cancel();
}
Console.WriteLine("Encrypting: " + e.ProgressPercentage + "%\n");
};
var testfileRaw = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "MyAwesomeChipmunkKiller.jpg");
const string privateKey = "1158b1ea7d45919968b87dab6cab27eff5871304ea9856588e9ec02a6d93c42e";
const string publicKey = "1158b1ea7d45919968b87dab6cab27eff5871304ea9856588e9ec02a6d93c42e";
var testKeyPair = new KeyPair(Utilities.HexToBinary(publicKey), Utilities.HexToBinary(privateKey));
Assert.ThrowsAsync<TaskCanceledException>(async () => await
Cryptor.EncryptFileWithStreamAsync(testKeyPair, testfileRaw, progressEncrypt,
Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "decrypted"), ".sccef",
cancellationToken: cancellationTokenSource.Token));
}