public void TestEncryptStreamAsyncValidatesSourceStreamNotNull()
 {
     ValeoInterviewChallenge.CryptographyService.XorCryptographyService xorCryptographyService = new ValeoInterviewChallenge.CryptographyService.XorCryptographyService();
     using (var target = new MemoryStream())
     {
         //unfortunately this test is failing, because async methods are not supported by Assert.ThrowsException
         Assert.ThrowsException <ArgumentNullException>(async() => await xorCryptographyService.EncryptStreamAsync(null, target, "aaa", null));
     }
 }
        public async Task TestFileEncryptionAndDecryption()
        {
            string sourceText = "01234567989";

            using (MemoryStream sourceStream = new MemoryStream(Encoding.UTF8.GetBytes(sourceText)))
            {
                using (MemoryStream targetStream = new MemoryStream())
                {
                    using (MemoryStream targetValidationStream = new MemoryStream())
                    {
                        string passPhrase = "01234567";
                        ValeoInterviewChallenge.CryptographyService.XorCryptographyService xorCryptographyService = new ValeoInterviewChallenge.CryptographyService.XorCryptographyService();
                        await xorCryptographyService.EncryptStreamAsync(sourceStream, targetStream, passPhrase, null);

                        Assert.AreEqual(sourceStream.Length, targetStream.Length);
                        targetStream.Position = 0;
                        await xorCryptographyService.DecryptStreamAsync(targetStream, targetValidationStream, passPhrase, null);

                        Assert.AreEqual(sourceStream.Length, targetValidationStream.Length);
                        targetValidationStream.Position = 0;
                        StreamReader streamReader = new StreamReader(targetValidationStream);
                        Assert.AreEqual(sourceText, streamReader.ReadToEnd());
                    }
                }
            }
        }