コード例 #1
0
        static async void StartDownloading()
        {
            var recordManager = JustDownloadFactory.GetRecordManager();
            var downloader    = JustDownloadFactory.GetDownloader();

            try
            {
                var records = await recordManager.GetRecords();

                if (records?.Any() ?? false)
                {
                    Console.WriteLine("Starting downloads...");

                    await downloader.GetFiles(records);
                }
                else
                {
                    Console.WriteLine("No download records found.");
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
            }
        }
コード例 #2
0
        public async Task TestGetRecords()
        {
            var recordMgr = JustDownloadFactory.GetRecordManager();

            var records = await recordMgr.GetRecords();

            Assert.IsNotNull(records);
            Assert.IsTrue(records.Count > 0);
        }
コード例 #3
0
        public async Task TestGetRecords_InvalidScheme()
        {
            var filePath  = Path.Combine(Directory.GetCurrentDirectory(), "invalidscheme.txt");
            var recordMgr = JustDownloadFactory.GetRecordManager(new Dictionary <ConfigKey, object>()
            {
                { ConfigKey.TextRecordManagerFilePath, filePath }
            });

            var exception = await Assert.ThrowsExceptionAsync <Exception>(async() =>
            {
                await recordMgr.GetRecords();
            });

            Assert.IsNotNull(exception);
        }