CompareFiles() public static method

public static CompareFiles ( string fileName1, string fileName2 ) : bool
fileName1 string
fileName2 string
return bool
Beispiel #1
0
        public void EncryptManifestFilesAndVerifyThemAfterDecryption()
        {
            List <IIngestManifestFile> files;
            IIngestManifest            ingestManifestCreated;
            string path = null;

            try
            {
                path = CreateManifestEncryptFiles(out files, out ingestManifestCreated);
                IIngestManifestAsset ingestManifestAsset = ingestManifestCreated.IngestManifestAssets.ToList().Where(c => c.Asset.Options == AssetCreationOptions.StorageEncrypted).FirstOrDefault();
                IIngestManifestFile  mFile = ingestManifestAsset.IngestManifestFiles.Where(c => c.Name == "File0.txt").FirstOrDefault();

                Dictionary <string, string> filePaths = new Dictionary <string, string>();
                foreach (var filePath in new[] { TestFile1, TestFile2 })
                {
                    FileInfo fileInfo = new FileInfo(filePath);
                    filePaths.Add(fileInfo.Name, filePath);
                }

                var encryptedPath = Path.Combine(path, mFile.Name);
                Assert.IsTrue(File.Exists(encryptedPath));
                var decryptedPath = DecryptedFile(mFile, encryptedPath, _mediaContext);
                Assert.IsTrue(AssetTests.CompareFiles(decryptedPath, filePaths[mFile.Name]), "Original file and Decrypted are not same");
            }
            finally
            {
                AssetFilesTests.CleanDirectory(path);
            }
        }
        private static void EncryptFilesDecryptAndCompare(List <string> files)
        {
            CloudMediaContext context = WindowsAzureMediaServicesTestConfiguration.CreateCloudMediaContext();
            //Creating empty manifest
            const string    manifestName          = "Manifest 1";
            IIngestManifest ingestManifestCreated = context.IngestManifests.Create(manifestName);

            //Adding manifest asset info with multiple file
            IAsset emptyAsset = context.Assets.Create(Guid.NewGuid().ToString(), AssetCreationOptions.StorageEncrypted);

            IIngestManifestAsset ingestManifestAsset = ingestManifestCreated.IngestManifestAssets.CreateAsync(emptyAsset, files.ToArray(), CancellationToken.None).Result;

            var path = @".\Resources\TestFiles\" + Guid.NewGuid();

            Directory.CreateDirectory(path);
            ingestManifestCreated.EncryptFiles(path);

            Dictionary <string, string> filePaths = new Dictionary <string, string>();

            foreach (var filePath in files)
            {
                FileInfo fileInfo = new FileInfo(filePath);
                filePaths.Add(fileInfo.Name, filePath);
            }


            foreach (var assetFile in ingestManifestAsset.IngestManifestFiles)
            {
                var encryptedPath = Path.Combine(path, assetFile.Name);
                Assert.IsTrue(File.Exists(encryptedPath));
                var decryptedPath = DecryptedFile(assetFile, encryptedPath, context);
                Assert.IsTrue(AssetTests.CompareFiles(decryptedPath, filePaths[assetFile.Name]), "Original file and Decrypted are not same");
            }
        }