public void FileExtensions_Tests()
        {
            const string testFileData = "A whole new testing world.";

            using (new Impersonation(Domain, Username, Password))
            {
                // To complex to go build path up to directory, keep this as is.
                Assert.IsTrue(Directory.Exists(WebsiteSharePath));
            }

            var originalDirectory = WebsiteSharePath + "TestFolder1";

            using (new Impersonation(Domain, Username, Password))
            {
                FileExtensions.CreateDirectories(originalDirectory, FolderList, Domain, Username);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\data.txt", Domain, Username, testFileData);
                Assert.IsTrue(File.Exists(originalDirectory + @"\File Sharing\data.txt"));

                FileExtensions.AppendFile(originalDirectory + @"\File Sharing\data.txt", Domain, Username, testFileData);

                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExamplePdf.pdf", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleXls.xls", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleXlsx.xlsx", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleXlsb.xlsb", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleXlsm.xlsm", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleCsv.csv", Domain, Username, testFileData);
                FileExtensions.CreateFile(originalDirectory + @"\File Sharing\ExampleCsv.csvX", Domain, Username, testFileData);
                var linqFiles =
                    Directory.GetFiles(originalDirectory + @"\File Sharing\")
                    .Where(s => s.EndsWith(".pdf") || s.EndsWith(".xls") || s.EndsWith(".xlsx") ||
                           s.EndsWith(".xlsb") || s.EndsWith(".xlsm") || s.EndsWith(".csv")).ToList();
                Assert.AreEqual(linqFiles.Count, 6);
            }

            var newDirectory = WebsiteSharePath + "TestFolder2";

            using (new Impersonation(Domain, Username, Password))
            {
                FileExtensions.RemapDirectory(originalDirectory, newDirectory, Domain, Username);
                FileExtensions.CreateDirectories(newDirectory, FolderList, Domain, Username);

                Assert.IsFalse(Directory.Exists(originalDirectory));
                Assert.IsTrue(File.Exists(newDirectory + @"\File Sharing\data.txt"));
            }

            using (new Impersonation(Domain, Username, Password))
            {
                FileExtensions.DeleteDirectories(newDirectory, Domain, Username);
                Assert.IsFalse(Directory.Exists(newDirectory));
            }
        }
        public void FileExtensions_AesTests()
        {
            const string testFileData = "A whole new testing world.";
            var          folderList   = new List <string> {
                "Aes"
            };
            var baseFolderPath = string.Format(@"{0}{1}", WebsiteSharePath, @"Aes");
            var baseFilePath   = string.Format(@"{0}\{1}", baseFolderPath, "AesFile_");

            using (new Impersonation(Domain, Username, Password))
            {
                Assert.IsTrue(Directory.Exists(WebsiteSharePath));
                FileExtensions.CreateDirectories(WebsiteSharePath, folderList, Domain, Username);

                // CreateFile | ReadFile
                var createFilePath = string.Format("{0}{1}", baseFilePath, "CreateFile.txt");
                FileExtensions.CreateFile(createFilePath, Domain, Username, testFileData);
                var createFileData = FileExtensions.ReadFile(createFilePath, Domain, Username);
                Assert.AreEqual(testFileData, createFileData);

                // CreateFileAsync | ReadFileAsync
                var createFileAsyncPath = string.Format("{0}{1}", baseFilePath, "CreateFileAsync.txt");
                FileExtensions.CreateFileAsync(createFileAsyncPath, Domain, Username, testFileData).Wait();
                var createFileDataAsync = FileExtensions.ReadFileAsync(createFileAsyncPath, Domain, Username).Result;
                Assert.AreEqual(testFileData, createFileDataAsync);

                // CreateAesEncryptedFile | ReadAesEncryptedFile
                var createAesEncryptedFilePath = string.Format("{0}{1}", baseFilePath, "CreateAesEncryptedFile.txt");
                FileExtensions.CreateAesEncrytpedFile(createAesEncryptedFilePath, Domain, Username, testFileData,
                                                      AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize);
                var createAesEncryptedFileData = FileExtensions.ReadAesEncryptedFile(createAesEncryptedFilePath, Domain, Username,
                                                                                     AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize);
                Assert.AreEqual(testFileData, createAesEncryptedFileData);

                // CreateAesEncryptedFileAsync | ReadAesEncryptedFileAsync
                var createAesEncryptedFileAsyncPath = string.Format("{0}{1}", baseFilePath, "CreateAesEncryptedFileAsync.txt");
                FileExtensions.CreateAesEncrytpedFileAsync(createAesEncryptedFileAsyncPath, Domain, Username, testFileData,
                                                           AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Wait();
                var createAesEncryptedFileDataAsync = FileExtensions.ReadAesEncryptedFileAsync(createAesEncryptedFileAsyncPath, Domain, Username,
                                                                                               AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Result;
                Assert.AreEqual(testFileData, createAesEncryptedFileDataAsync);

                var appendTestFileData = testFileData + testFileData;

                // AppendFile | ReadFile
                var appendFilePath = string.Format("{0}{1}", baseFilePath, "AppendFile.txt");
                FileExtensions.CreateFile(appendFilePath, Domain, Username, testFileData);
                FileExtensions.AppendFile(appendFilePath, Domain, Username, testFileData);
                var appendFileData = FileExtensions.ReadFile(appendFilePath, Domain, Username);
                Assert.AreEqual(appendTestFileData, appendFileData);

                // AppendFileAsync | ReadFileAsync
                var appendFileAsyncPath = string.Format("{0}{1}", baseFilePath, "AppendFileAsync.txt");
                FileExtensions.CreateFileAsync(appendFileAsyncPath, Domain, Username, testFileData).Wait();
                FileExtensions.AppendFileAsync(appendFileAsyncPath, Domain, Username, testFileData).Wait();
                var appendFileDataAsync = FileExtensions.ReadFileAsync(appendFileAsyncPath, Domain, Username).Result;
                Assert.AreEqual(appendTestFileData, appendFileDataAsync);

                // AppendAesEncryptedFile | ReadAesEncryptedFile
                var appendAesEncryptedFilePath = string.Format("{0}{1}", baseFilePath, "AppendAesEncryptedFile.txt");
                FileExtensions.CreateAesEncrytpedFile(appendAesEncryptedFilePath, Domain, Username, testFileData,
                                                      AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize);
                FileExtensions.AppendAesEncrytpedFile(appendAesEncryptedFilePath, Domain, Username, testFileData,
                                                      AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize);
                var appendAesEncryptedFileData = FileExtensions.ReadAesEncryptedFile(appendAesEncryptedFilePath, Domain, Username,
                                                                                     AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize);
                Assert.AreEqual(appendTestFileData, appendAesEncryptedFileData);

                // AppendAesEncryptedFileAsync | ReadAesEncryptedFileAsync
                var appendAesEncryptedFileAsyncPath = string.Format("{0}{1}", baseFilePath, "AppendAesEncryptedFileAsync.txt");
                FileExtensions.CreateAesEncrytpedFileAsync(appendAesEncryptedFileAsyncPath, Domain, Username, testFileData,
                                                           AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Wait();
                FileExtensions.AppendAesEncrytpedFileAsync(appendAesEncryptedFileAsyncPath, Domain, Username, testFileData,
                                                           AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Wait();
                var appendAesEncryptedFileDataAsync = FileExtensions.ReadAesEncryptedFileAsync(appendAesEncryptedFileAsyncPath, Domain, Username,
                                                                                               AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Result;
                Assert.AreEqual(appendTestFileData, appendAesEncryptedFileDataAsync);

                // AppendAesEncryptedFileBytesAsync | ReadAesEncryptedFileBytesAsync
                var testFileDataBytes = Encoding.UTF32.GetBytes(testFileData);
                var appendAesEncryptedFileBytesAsyncPath = string.Format("{0}{1}", baseFilePath, "AppendAesEncryptedFileBytesAsync.txt");
                FileExtensions.CreateAesEncrytpedFileBytesAsync(appendAesEncryptedFileBytesAsyncPath, Domain, Username, testFileDataBytes,
                                                                AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Wait();
                FileExtensions.AppendAesEncrytpedFileBytesAsync(appendAesEncryptedFileBytesAsyncPath, Domain, Username, testFileDataBytes,
                                                                AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Wait();
                var appendAesEncryptedFileDataBytesAsync = FileExtensions.ReadAesEncryptedFileBytesAsync(appendAesEncryptedFileBytesAsyncPath, Domain, Username,
                                                                                                         AesPassword, AesSalt, AesPasswordIterations, AesInitialVector, AesKeySize).Result;
                var appendAesEncryptedFileDataDecodedAsync = Encoding.UTF32.GetString(appendAesEncryptedFileDataBytesAsync);
                Assert.AreEqual(appendTestFileData, appendAesEncryptedFileDataDecodedAsync);

                FileExtensions.DeleteDirectories(baseFolderPath, Domain, Username);
                Assert.IsFalse(Directory.Exists(baseFolderPath));
            }
        }