Пример #1
0
        private bool InvokeDownload(string remoteFile, string destFile, short chunkCount)
        {
            string        downloadUrl = DownloadDir + remoteFile + ".txt";
            WebDownloader downloader  = DownloaderFactory.GetDownloader(new TransferParameter()
            {
                ChunkCount = chunkCount, Environment = _environment, TransferUrl = downloadUrl, LocalFile = destFile, RemoteFile = remoteFile, SupportBrokenResume = _supportBorkenResume, SupportDebug = _supportDebug
            });

            try
            {
                bool hasFinished = false;
                downloader.Completed += new CompletedEventHandler(OnCompleted);
                downloader.Completed +=
                    new CompletedEventHandler(
                        delegate(object sender, CompletedEventArgs args) { hasFinished = true; });
                downloader.ExceptionError +=
                    new ExceptionEventHandle(
                        delegate(object sender, ExceptionEventArgs args) { hasFinished = true; });
                downloader.ExceptionError += new ExceptionEventHandle(OnException);
                downloader.Progress       += new ProgressEventHandle(OnProgress);
                downloader.Start();
                while (!hasFinished)
                {
                    Thread.Sleep(100);
                }
                return(true);
            }
            catch (Exception ex)
            {
                _errmsg = ex.Message;
                throw new ApplicationException(ex.Message);
            }
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine($"=== Anime Video Downloader App - {Assembly.GetExecutingAssembly().GetName().Version} ===");
            Console.CursorVisible = false;
            var progress = new Progress <DownloadProgressData>(d => OnProgressChanged(null, d));

            progress.ProgressChanged += OnProgressChanged;

            if (args.Length < 2)
            {
                Console.WriteLine("Download URL and DownloadPath is needed.");
                return;
            }

            var episodesUrl       = new Uri(args[0]);
            var downloadDirectory = args[1];

            using var downloader = new DownloaderFactory().GetDownloaderForSite(episodesUrl, new DownloaderConfig()
            {
                DownloadDirectory = downloadDirectory
            });
            _episodes = await downloader.GetEpisodesAsync();

            await downloader.DownloadAllEpisodesAsync();
        }
Пример #3
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")));
        }
Пример #4
0
        public void GetDownloaderFileShareComponentTypeTest()
        {
            var        target        = new DownloaderFactory();
            IComponent componentType =
                new Component(
                    new DependencyProviderConfig
            {
                Type     = ComponentType.FileShare.ToString(),
                Settings =
                    new DependencyProviderSettings
                {
                    SettingsList =
                        new List <IDependencyProviderSetting>
                    {
                        new DependencyProviderSetting
                        {
                            Name  = DependencyProviderValidSettingName.ComponentName,
                            Value = "Test"
                        },
                        new DependencyProviderSetting
                        {
                            Name  = DependencyProviderValidSettingName.VersionNumber,
                            Value = "123"
                        }
                    }
                }
            });

            var actual = target.GetDownloader(componentType);

            Assert.AreNotEqual(actual, null);
            Assert.AreEqual(actual.DownloadType, "Downloader_FileShareCopy");
        }
Пример #5
0
        public ActionResult <IDownloadItem> Post(ContentItem item)
        {
            var dl = new DownloadItem(item, DownloaderFactory.GetBestMatch(item.DownloadLinks));

            DownloadManager.Instance.Enqueue(dl);

            return(CreatedAtAction(nameof(Get), new { guid = dl.Id }, dl));
        }
Пример #6
0
        public void GetDownloaderUnknownPluginStringTest()
        {
            var target = new DownloaderFactory();
            var emptyDownloaderName = string.Empty;

            // Unknown downloader name should cause DependencyManagementFoundationPluginNotFoundException
            target.GetDownloader(emptyDownloaderName);
        }
Пример #7
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>());
        }
Пример #8
0
 public void CleanUp()
 {
     DownloaderFactory.Dispose();
     try {
         System.IO.File.Delete(bassPacketPath);
     } catch (Exception e) {
         Debug.Log(e.Message);
     }
 }
Пример #9
0
        static DownloaderFactory InitDownloaderFactory()
        {
            var downloaderThunks = new Dictionary <PageType, Func <Request, PageType, IDownloader> >();

            downloaderThunks.Add(PageType.Static, (req, pageType) => new HttpClientDownloader(req, pageType));
            var factory = new DownloaderFactory(downloaderThunks);

            return(factory);
        }
Пример #10
0
        public void GetDownloaderSourceControlMappingAliasDownloaderNameTest()
        {
            var          target         = new DownloaderFactory();
            const string downloaderName = "Downloader_SourceControl";

            var actual = target.GetDownloader(downloaderName);

            Assert.AreNotEqual(actual, null);
            Assert.AreEqual(actual.DownloadType, "Downloader_SourceControlMapping");
        }
Пример #11
0
        public void GetDownloaderFileShareCopyAliasDownloaderNameTest()
        {
            var          target         = new DownloaderFactory();
            const string downloaderName = "Downloader_FileShare";

            var actual = target.GetDownloader(downloaderName);

            Assert.AreNotEqual(actual, null);
            Assert.AreEqual(actual.DownloadType, "Downloader_FileShareCopy");
        }
Пример #12
0
        public void GetDownloaderZippedDependencyDownloaderNameTest()
        {
            var          target         = new DownloaderFactory();
            const string downloaderName = "Downloader_ZippedDependency";

            var actual = target.GetDownloader(downloaderName);

            Assert.AreNotEqual(actual, null);
            Assert.AreEqual(actual.DownloadType, downloaderName);
        }
        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)));
        }
        static public void Initialize(IDownloader downloader)
        {
            Assembly assembly = Assembly.GetAssembly(typeof(DownloaderFactory));
            Type     type     = assembly.GetType("Doubility3D.Resource.Downloader.DownloaderFactory");

            DownloaderFactory df    = DownloaderFactory.Instance;
            BindingFlags      flag  = BindingFlags.NonPublic | BindingFlags.Instance;
            FieldInfo         f_key = type.GetField("downloader", flag);

            f_key.SetValue(df, downloader);
        }
Пример #15
0
        public void MainTask(int taskId)
        {
            DownloaderBase downloader = DownloaderFactory.Create(this.Type);

            while (true)
            {
                TaskInfo taskInfo = this.TaskQueue.Take();
                Diagnostics.WriteDebugTrace($"TaskId={taskId}. Get task from queue. Url={taskInfo.Url}", Diagnostics.DebugLevel.Debug);
                this.DownloaderDict.AddOrUpdate(taskId, downloader, (k, v) => downloader);
                downloader.Download(taskInfo);
            }
        }
Пример #16
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);
        }
Пример #17
0
        private void StartDown(EventParameter eventParameter)
        {
            IDownloader downloader = DownloaderFactory.Creator(eventParameter.Category.DownUrl);

            if (downloader == null)
            {
                return;
            }

            DownParameter downParameter = new DownParameter(eventParameter.Category);

            downloader.Down(downParameter);
        }
Пример #18
0
    async void Start()
    {
        var downloader = DownloaderFactory.Create(Provider.PlayerIO);
        var config     = new CDNCache.Config {
            rootDir = Application.persistentDataPath + "/PlayerIOCDNExample/",
            versionFileNomenclatureMethod = (fileName, onSuccess, onFailure) =>
                                            onSuccess?.Invoke(fileName + "_version.txt")
        };

        await m_Cache.Init(config, downloader);

        Debug.Log("CDN Cache initialized");
    }
        /// <summary>
        /// Reverts an individual component
        /// </summary>
        /// <param name="dwSvc">The watermark service to use</param>
        /// <param name="name">The name of the component</param>
        /// <param name="version">The version of the component</param>
        internal void RevertComponent(DownloadWatermarkService dwSvc, string name, string version)
        {
            var dFac = new DownloaderFactory();
            IDependencyDownloaderWatermark wm = null;
            var wmName    = name;
            var wmVersion = version;

            try
            {
                wm = dwSvc.Load(name, version);

                if (null == wm)
                {
                    // TODO: might consider logging this to a trace file
                    Debug.Fail(
                        string.Format(
                            "Unable to load a watermark for component {0}@{1}. This situation should never occur due to the fact that the same method is reading and writing the watermarks",
                            name,
                            version));
                }

                // Read name and version information from watermark (saving can convert name and version back to hashes).
                if (wm.Tags.ContainsKey("name"))
                {
                    wmName = wm.Tags["name"];
                }
                if (wm.Tags.ContainsKey("version"))
                {
                    wmVersion = wm.Tags["version"];
                }

                var cleaner = dFac.GetDownloader(wm.DownloadType);
                Logger.Instance().Log(TraceLevel.Info, "{0}: Cleaning component {1}#{2} ...", CommandType, wmName, wmVersion);
                cleaner.RevertDownload(wm);

                dwSvc.Delete(wm);
            }
            catch
            {
                if (null != wm)
                {
                    dwSvc.Save(wm, name, version);
                }
            }

            if (!_silentMode)
            {
                _logger.LogMsg(string.Format("  * Component {0} (Version:{1}) cleaned.", wmName, wmVersion));
            }
            Logger.Instance().Log(TraceLevel.Info, "{0}: Component {1}#{2} successfully cleaned", CommandType, wmName, wmVersion);
        }
        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));
        }
Пример #22
0
 public void Clear()
 {
     DownloaderFactory.Dispose();
     downloader = null;
     try {
         for (int i = 0; i < packetPath.Length; i++)
         {
             System.IO.File.Delete(packetPath [i]);
             dictPacket [i].Clear();
         }
         packetPath = null;
         dictPacket = null;
     } catch (Exception e) {
         Debug.Log(e.Message);
     }
 }
Пример #23
0
        public void GetDownloaderFileShareZippedDependencyComponentTypeTestNoDeletionSetting_ShouldBeFalse()
        {
            var        target        = new DownloaderFactory();
            IComponent componentType =
                new Component(
                    new DependencyProviderConfig
            {
                Type     = ComponentType.FileShare.ToString(),
                Settings =
                    new DependencyProviderSettings
                {
                    SettingsList =
                        new List <IDependencyProviderSetting>
                    {
                        new DependencyProviderSetting
                        {
                            Name  = DependencyProviderValidSettingName.ComponentName,
                            Value = "Test"
                        },
                        new DependencyProviderSetting
                        {
                            Name  = DependencyProviderValidSettingName.VersionNumber,
                            Value = "123"
                        },
                        new DependencyProviderSetting
                        {
                            Name  = DependencyProviderValidSettingName.CompressedDependency,
                            Value = "True"
                        }
                    }
                }
            });
            object actual = null;

            try
            {
                actual = target.GetDownloader(componentType);
            }
            catch (Exception ae)
            {
                Assert.AreEqual("The settings is missing that determines if the archive files should be deleted, please make sure it is set accordingly", ae.Message);
            }


            Assert.IsNotNull(actual);
        }
        private void CheckEpisodesButton_OnClick(object sender, RoutedEventArgs e)
        {
            LoadingBar.Visibility = Visibility.Visible;
            var episodeUrl = EpisodeUrlTextBox.Text;

            if (!Uri.TryCreate(episodeUrl, UriKind.Absolute, out var uri))
            {
                MessageBox.Show("Episode link is invalid.", "Error", MessageBoxButton.OK);
                return;
            }

            var downloadDirectory = DownloadDirectoryTextBox.Text;

            if (string.IsNullOrWhiteSpace(downloadDirectory))
            {
                MessageBox.Show("Download directory is invalid.", "Error", MessageBoxButton.OK);
                return;
            }

            var tempData = new TempData {
                LatestDownloadPath = DownloadDirectoryTextBox.Text,
                LatestDownloadUri  = EpisodeUrlTextBox.Text
            };

            TempDataSaver.Save(tempData);

            var factory          = new DownloaderFactory();
            var downloaderConfig = new DownloaderConfig {
                ShouldDownloadFillers = DownloadFillersCheckbox.IsChecked.Value,
                Checkpoint            = new JsonCheckpoint(),
                DownloadDirectory     = downloadDirectory,
            };
            var downloader = factory.GetDownloaderForSite(uri, downloaderConfig);

            if (downloader == null)
            {
                MessageBox.Show($"Site:\n {uri} not supported yet.", "Site not supported", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }
            LoadingBar.Visibility = Visibility.Collapsed;
            this.Content          = new DownloadUserControl(downloader);
        }
Пример #25
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")));
        }
Пример #26
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")));
        }
Пример #27
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")));
        }
Пример #28
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));
        }
Пример #30
0
 protected override void TestFixtureTeardown()
 {
     ShaderManager.Instance.DisposeBundle();
     ShaderManager.shaderDictPath = oldShaderDict;
     DownloaderFactory.Dispose();
 }