Exemple #1
0
        public void ShouldNotNeedManyServices_WhenDummyDownloaderImplementation()
        {
            string seriesDir = Path.Combine(Environment.CurrentDirectory,
                                            "tests", "ShouldNotNeedManyServices_WhenDummyDownloaderImplementation");
            var batchNumberService      = new BatchNumberService();
            CancellationTokenSource cts = new CancellationTokenSource();
            var downloader = new SingleInstrumentDownloadServiceDryRun(batchNumberService);
            var service    = new HistoricalPricesDownloadService(downloader);

            var instruments = new string[] { "BTC_USD", "ETC_USD" };

            service.DownloadAndSave(instruments, 12, seriesDir, cts.Token);
            Assert.False(File.Exists(Path.Combine(seriesDir, "12", "BTC_USD.csv")));
            Assert.False(File.Exists(Path.Combine(seriesDir, "12", "ETC_USD.csv")));
        }
Exemple #2
0
        public void ShouldInvokeExchangeWithCorrectDateRanges()
        {
            string           seriesDir       = Path.Combine(Environment.CurrentDirectory, "tests", "ShouldInvokeExchangeWithCorrectDateRanges");
            Mock <IExchange> exchangeService = new Mock <IExchange>(MockBehavior.Loose);
            var batchNumberService           = new BatchNumberService();
            var filePathService = new FilePathService();

            CancellationTokenSource    cts           = new CancellationTokenSource();
            Mock <IEventSavingService> savingService = new Mock <IEventSavingService>(MockBehavior.Loose);
            var downloader = new SingleInstrumentDownloadService(exchangeService.Object,
                                                                 batchNumberService, filePathService, savingService.Object);
            var service = new HistoricalPricesDownloadService(downloader);

            var instruments = new string[] { "BTC_USD", "ETC_USD" };

            service.DownloadAndSave(instruments, 12, seriesDir, cts.Token);

            exchangeService.Verify(
                g => g.GetHistoricalPrices("BTC_USD", 300,
                                           // batch12 start - 15 minutes
                                           DateTimeExtensions.CreateNodaTime(2019, 4, 27, 23, 45, 0),
                                           // batch12 end + 15 minutes
                                           DateTimeExtensions.CreateNodaTime(2019, 5, 5, 0, 14, 59)
                                           ),
                Times.Exactly(1)
                );
            exchangeService.Verify(
                g => g.GetHistoricalPrices("ETC_USD", 300,
                                           DateTimeExtensions.CreateNodaTime(2019, 4, 27, 23, 45, 0),
                                           DateTimeExtensions.CreateNodaTime(2019, 5, 5, 0, 14, 59)
                                           ),
                Times.Exactly(1)
                );
            exchangeService.VerifyNoOtherCalls();
            Assert.False(File.Exists(Path.Combine(seriesDir, "12", "BTC_USD.csv")));
        }