Ejemplo n.º 1
0
        public void DownloadsFileOnceConcurrently()
        {
            var dataProvider = new ApiDataProviderTest();

            var tasks = new List <Task>();

            for (var i = 0; i < 10; i++)
            {
                tasks.Add(Task.Factory.StartNew(() =>
                                                dataProvider.Fetch(Path.Combine(Globals.DataFolder, "equity", Market.USA, "hour", "f.zip"))));
            }

            tasks.ForEach(task => task.Wait());
            dataProvider.DisposeSafely();
            Assert.AreEqual(1, dataProvider.DownLoadCount);
        }
Ejemplo n.º 2
0
        [TestCase("futureoption/cme/minute/es/20200320/20200105_quote_american.zip", 10, false)] // Date based minute data
        // Index Cases / Index Option Cases *Not included because not allowed to download
        public void ShouldDownloadTest(string file, int days, bool expected)
        {
            // First create our test file and set its time
            var path      = Path.Combine("./ApiDataTests", file);
            var time      = DateTime.Now - TimeSpan.FromDays(days);
            var directory = Path.GetDirectoryName(path);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            File.Create(path).Dispose();
            File.SetLastWriteTime(path, time);

            var dataProvider = new ApiDataProviderTest();
            var result       = dataProvider.NeedToDownloadExposed(path);

            Assert.AreEqual(expected, result);

            // Cleanup after test
            File.Delete(path);
        }