Tests.WorkAsyncTest.WorkWithImageFileAndWrongKeyTestAsync C# (CSharp) Method

WorkWithImageFileAndWrongKeyTestAsync() private method

private WorkWithImageFileAndWrongKeyTestAsync ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
		public async Task WorkWithImageFileAndWrongKeyTestAsync()
		{
			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));
			var testKeyPair = PublicKeyBox.GenerateKeyPair();
			Console.Write("Encrypting testfile . . .\n");
			//encrypt the file with an ephmeral key
			var encryptedFile =
				await
					Cryptor.EncryptFileWithStreamAsync(keyPair, testKeyPair.PublicKey, rawFile, null, outputDirectory,
						".test", true);
			Console.Write("Decrypting testfile . . .\n");
			//try to decrypt with an wrong key
			var decryptedFile =
				Assert.ThrowsAsync<CryptographicException>(
					async () => await
						Cryptor.DecryptFileWithStreamAsync(keyPair,
							Path.Combine(TestContext.CurrentContext.TestDirectory, outputDirectory, encryptedFile),
							outputDirectory));


			File.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, outputDirectory, encryptedFile));
		}