Ejemplo n.º 1
0
        public void Download_Subversion_IncludeFiles_ExcludeFolder()
        {
            //Create the excludefilter
            var filefilter   = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.IncludedFilesFilter, "*.cs");
            var folderfilter = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.ExcludedFilesFilter, _subFolderLogging + "\\");
            var settings     = new DependencyService.Settings <DownloaderValidSettings>();

            settings.AddSetting(filefilter);
            settings.AddSetting(folderfilter);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class4.cs")));
            //The targets file should not be there
            Assert.IsFalse(File.Exists(Path.Combine(_downloadDir, "component.targets")));
            //The subfolder Logging should no be there, too
            Assert.IsFalse(File.Exists(Path.Combine(_downloadDir, _subFolderLogging, "LoggingClass.cs")));
        }
Ejemplo n.º 2
0
        public DownloaderWatermark(IDependencyDownloader downloader)
        {
            if (null == downloader)
            {
                throw new ArgumentNullException("downloader");
            }

            DownloadType = downloader.DownloadType;
        }
Ejemplo n.º 3
0
        //Einzelne Dateien herunterladen sinnvoll?
        public void Download_Subversion_DownloadNotExistingFile()
        {
            string notExistingFile = string.Format("{0}/{1}/{2}", _svnSrcPath, _componentA, "notExistingFile");

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(notExistingFile, _downloadDir, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());
        }
        public void Download_FileShare_ExcludeFilterChildLevel_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string subDir1   = "subDir1";
            string subDir2   = "subDir2";
            string testFile1 = "TestFile1.txt";
            string testFile2 = "TestFile2.txt";
            string testFile3 = "TestFile3.txt";
            string testFile4 = "TestXml1.xml";
            string testFile5 = "TestXml2.xml";
            string testFile6 = "TestXml3.xml";
            string testFile7 = "TestCs1.cs";
            string testFile8 = "TestCs2.cs";
            string testFile9 = "TestCs3.cs";

            Directory.CreateDirectory(Path.Combine(sourceDir, subDir1));
            Directory.CreateDirectory(Path.Combine(sourceDir, subDir2));
            File.Create(Path.Combine(sourceDir, subDir1, testFile1)).Close();
            File.Create(Path.Combine(sourceDir, subDir1, testFile2)).Close();
            File.Create(Path.Combine(sourceDir, subDir1, testFile3)).Close();
            File.Create(Path.Combine(sourceDir, testFile4)).Close();
            File.Create(Path.Combine(sourceDir, testFile5)).Close();
            File.Create(Path.Combine(sourceDir, testFile6)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile7)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile8)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile9)).Close();

            IDependencyDownloaderFactory        df         = new DownloaderFactory();
            IDependencyDownloader               downloader = df.GetDownloader("Downloader_FileShare");
            ISettings <DownloaderValidSettings> settings   = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.ExcludedFilesFilter, "subdir1\\"));
            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, settings);

            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile1)));
            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile2)));
            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile3)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile4)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile5)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile6)));
            Assert.IsFalse(Directory.Exists(Path.Combine(destDir, subDir1)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile7)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile8)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile9)));
        }
Ejemplo n.º 5
0
        public void Download_Subversion_DownloadNotExistingFolder()
        {
            string notExistingFolder = string.Format("{0}/{1}", _svnSrcPath, "notExistingFolder");

            var settings = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(notExistingFolder, _downloadDir, new DummyWatermark(), false, settings);
        }
        public void Download_NonExistingSourceDir_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_FileShare");

            downloader.Download(compRootDir + Path.DirectorySeparatorChar + "testComp", tempPath, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());
        }
        public void Download_FileShare_FileTypeFilter_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string testDir   = "testDir";
            string testFile1 = "TestFile1.txt";
            string testFile2 = "testFile2.dll";
            string testFile3 = "testXml1.xml";
            string testFile4 = "Abcd.txt";

            Directory.CreateDirectory(sourceDir + Path.DirectorySeparatorChar + testDir);
            StreamWriter tf1 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1);

            tf1.WriteLine(testFile1);
            tf1.Close();
            StreamWriter tf2 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile2);

            tf2.WriteLine(testFile2);
            tf2.Close();
            StreamWriter tf3 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile3);

            tf3.WriteLine(testFile3);
            tf3.Close();
            StreamWriter tf4 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile4);

            tf4.WriteLine(testFile4);
            tf4.Close();

            IDependencyDownloaderFactory        df         = new DownloaderFactory();
            IDependencyDownloader               downloader = df.GetDownloader("Downloader_FileShare");
            ISettings <DownloaderValidSettings> settings   = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.IncludedFilesFilter, "Test*.txt;*.dll"));
            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(Directory.Exists(destDir + Path.DirectorySeparatorChar + testDir));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testFile2));
            Assert.IsFalse(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile3));
            Assert.IsFalse(File.Exists(destDir + Path.DirectorySeparatorChar + testFile4));
        }
Ejemplo n.º 8
0
        public void Download_Subversion_DownloadExistingFolder_DestinationFolderNotExists()
        {
            Directory.CreateDirectory(_downloadDir);

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            var settings = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Logging", "LoggingClass.cs")));
        }
Ejemplo n.º 9
0
        public void Download_Subversion_FolderWithExternals()
        {
            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentWithExternals);

            var settings = new DependencyService.Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "UsingCommon.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon3.cs")));
        }
Ejemplo n.º 10
0
        public void Download_Subversion_FolderMappingsMoveToSubfolder()
        {
            var targetFolder = @"libs\ComponentA_V10";

            var settings = new DependencyService.Settings <DownloaderValidSettings>();
            //Create the folder mapping
            var mappings = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.FolderMappings, string.Format("SourceOffset={0}/{1},LocalOffset=.//", _componentA, _subFolderLogging));

            settings.AddSetting(mappings);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "ComponentA.1_0.dll")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "component.targets")));
        }
Ejemplo n.º 11
0
        public void Download_Subversion_FolderMappingsRenameFolderSameLevel()
        {
            var targetFolder = "ComponentA_renamed";

            var settings = new DependencyService.Settings <DownloaderValidSettings>();
            //Create the folder mapping
            var mappings = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.FolderMappings, string.Format("SourceOffset={0},LocalOffset={1};", _componentA, targetFolder));

            settings.AddSetting(mappings);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(_svnSrcPath, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class4.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "component.targets")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, _subFolderLogging, "LoggingClass.cs")));
        }
        public void Download_FileShare_ExistingComponent_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string testDir   = "testDir";
            string testFile1 = "testFile1.txt";
            string testFile2 = "testFile2.txt";

            Directory.CreateDirectory(sourceDir + Path.DirectorySeparatorChar + testDir);
            StreamWriter tf1 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1);

            tf1.WriteLine(testFile1);
            tf1.Close();
            StreamWriter tf2 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile2);

            tf2.WriteLine(testFile2);
            tf2.Close();

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_FileShare");

            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());

            Assert.IsTrue(Directory.Exists(destDir + Path.DirectorySeparatorChar + testDir));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testFile2));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ZippedDependencyDownloader"/> class.
 /// </summary>
 /// <param name="downloader">The download used to retrieve compressed files</param>
 public ZippedDependencyDownloader(IDependencyDownloader downloader, bool IsDeleteArchiveFiles)
 {
     _downloader           = downloader;
     _isDeleteArchiveFiles = IsDeleteArchiveFiles;
 }