Tests.DecryptExceptionAsyncTests.DecryptionCancellationTestAsync C# (CSharp) Method

DecryptionCancellationTestAsync() private method

private DecryptionCancellationTestAsync ( ) : void
return void
		public void DecryptionCancellationTestAsync()
		{
			var cancellationTokenSource = new CancellationTokenSource();
			var progressEncrypt = new Progress<StreamCryptorTaskAsyncProgress>();
			var progressDecrypt = new Progress<StreamCryptorTaskAsyncProgress>();
			progressEncrypt.ProgressChanged +=
				(s, e) => { Console.WriteLine("Encrypting: " + e.ProgressPercentage + "%\n"); };
			progressDecrypt.ProgressChanged +=
				(s, e) =>
				{
					if (e.ProgressPercentage > 10)
					{
						cancellationTokenSource.Cancel();
					}
					Console.WriteLine("Decrypting: " + e.ProgressPercentage + "%\n");
				};
			var rawFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "MyAwesomeChipmunkKiller.jpg");
			var outputDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "decrypted");
			const string privateKey = "31d9040b00a170532929b37db0afcb989e4175f96e5f9667ee8cbf5706679a71";
			const string publicKey = "6d0deec730700f9f60687a4e6e8755157ca22ea2f3815b9bf14b1fe9ae6a0b4d";
			var keyPair = new KeyPair(Utilities.HexToBinary(publicKey), Utilities.HexToBinary(privateKey));
			Console.Write("Encrypting testfile . . .\n");
			var encryptedFile = Cryptor.EncryptFileWithStream(keyPair.PrivateKey, keyPair.PublicKey,
				Utilities.HexToBinary(publicKey), rawFile, outputDirectory, ".test", true);
			Console.Write("Decrypting testfile . . .\n");
			Assert.ThrowsAsync<TaskCanceledException>(async () => await
				Cryptor.DecryptFileWithStreamAsync(keyPair.PrivateKey, Path.Combine(outputDirectory, encryptedFile),
					outputDirectory, progressDecrypt, cancellationToken: cancellationTokenSource.Token));
		}