Esempio n. 1
0
        public async Task TestWindowsNetworkFileCopy()
        {
            var destPath = ConfigSettings["TestUNCPath"];

            var credentialsManager = new CredentialsManager
            {
                StorageSubfolder = "credentials\\test"
            };

            var storedCred = await credentialsManager.GetUnlockedCredentialsDictionary(ConfigSettings["TestCredentialsKey_UNC"]);

            // create a test temp file
            var tmpPath = Path.GetTempFileName();

            File.WriteAllText(tmpPath, "This is a test temp file");
            var files = new List <FileCopy>
            {
                new FileCopy {
                    SourcePath = tmpPath, DestinationPath = destPath + @"\test-copy.txt"
                }
            };

            var credentials = Plugin.DeploymentTasks.Shared.Helpers.GetWindowsCredentials(storedCred);

            var client = new WindowsNetworkFileClient(credentials);

            // test file list
            var fileList = client.ListFiles(destPath);

            Assert.IsTrue(fileList.Count > 0);

            // test file copy
            var results = client.CopyLocalToRemote(_log, files);

            File.Delete(tmpPath);

            Assert.IsTrue(results.All(s => s.IsSuccess == true));
        }