Ejemplo n.º 1
0
        public async Task Should_AddNewSymbols_WhenExistingData()
        {
            int symbolCountFirstSync = await GetSymbolCount();

            var jpmSymbol = await _symbolRepo.GetSymbol("JPM");

            var msftSymbol = await _symbolRepo.GetSymbol("MSFT");

            await DeleteSymbol(jpmSymbol.Ticker, jpmSymbol.ExchangeId);
            await DeleteSymbol(msftSymbol.Ticker, msftSymbol.ExchangeId);

            int symbolCountAfterDelete = await GetSymbolCount();

            Assert.Equal(symbolCountFirstSync - 2, symbolCountAfterDelete);

            await ToggleSyncThreshold(true);

            await _sync.Sync();

            var readdSyncHistory = await GetLatestSyncHistory();

            Assert.Equal(nameof(NewSymbolChangeset), readdSyncHistory.ActionName);
            Assert.Equal(2, readdSyncHistory.SymbolsChanged);
        }
Ejemplo n.º 2
0
        public async Task InitializeAsync()
        {
            var mockDbOptions = new Mock <IOptionsMonitor <DbOptions> >();

            mockDbOptions.Setup(x => x.CurrentValue).Returns(new DbOptions
            {
                ConnectionString         = AppTestSettings.Instance.TestDBConnectionString,
                DefaultBulkCopyBatchSize = AppTestSettings.Instance.DefaultBulkCopyBatchSize
            });

            var nasdaqLogger         = new Mock <ILogger <NasdaqParser> >();
            var exchangeClientLogger = new Mock <ILogger <ExchangeClient> >();

            // Setup dependencies
            ExchangeSyncRepo = new ExchangeSyncRepository(mockDbOptions.Object);

            string nasdaqDownloadUrl = (await ExchangeSyncRepo.GetSyncSettings()).Url;

            // Stub FTP so we use downloaded file from disk instead of every test run
            var stubFTPClient = new CachedNasdaqClient(nasdaqDownloadUrl);

            var exchangeClient = new ExchangeClient(
                ftpClient: stubFTPClient,
                parser: new NasdaqParser(nasdaqLogger.Object),
                logger: exchangeClientLogger.Object);

            var changesetFactory = new ExchangeSyncChangesetsFactory();

            ExchangeSync = new ExchangeSync(exchangeClient, ExchangeSyncRepo, changesetFactory, new Mock <ILogger <ExchangeSync> >().Object);
            SymbolRepo   = new SymbolRepository(mockDbOptions.Object);

            await ToggleSyncThreshold(false);

            await ExchangeSync.Sync();

            await ToggleSyncThreshold(true);
        }