コード例 #1
0
        public void ImportData()
        {
            ICurrencyImporter importer         = new JsonCurrencyImporter();
            ICurrencyProvider currencyProvider = new NationalBankCurrencyProvider(importer);
            ICachingProcessor cachingProcessor = new ApiDatabaseCachingProcessor(currencyProvider, new MsSqlExplorerRepository(new CurrencyDataContext()));

            IDictionary <CurrencyCodeEntry, CurrencyDataEntry> data = null;

            try
            {
                data = cachingProcessor.RequestSingleData(DateTime.Now, new CurrencyCodeEntry[]
                {
                    new CurrencyCodeEntry()
                    {
                        Value = "36"
                    },
                    new CurrencyCodeEntry()
                    {
                        Value = "826"
                    }
                });

                Assert.Equal(2, data.Count);
            }
            catch (Exception e)
            {
                Assert.True(e is NoItemsException);
                Assert.Null(data);
            }
        }
コード例 #2
0
        public void ImportDataWithNullCurrencyCodes()
        {
            ICurrencyImporter importer         = new JsonCurrencyImporter();
            ICurrencyProvider currencyProvider = new NationalBankCurrencyProvider(importer);
            ICachingProcessor cachingProcessor = new ApiDatabaseCachingProcessor(currencyProvider, new MsSqlExplorerRepository(new CurrencyDataContext()));

            Action action = () =>
            {
                cachingProcessor.RequestSingleData(DateTime.Now, null);
            };

            Assert.ThrowsAny <NullReferenceException>(action);
        }
コード例 #3
0
        public void ImportPeriodicDataWhenCurrencyCodesAreEmpty()
        {
            ICurrencyImporter importer         = new JsonCurrencyImporter();
            ICurrencyProvider currencyProvider = new NationalBankCurrencyProvider(importer);
            ICachingProcessor cachingProcessor = new ApiDatabaseCachingProcessor(currencyProvider, new MsSqlExplorerRepository(new CurrencyDataContext()));

            ChartTimePeriod timePeriod = new ChartTimePeriod(DateTime.Now.Subtract(TimeSpan.FromDays(10)), DateTime.Now);

            var data = cachingProcessor.RequestPeriodData(timePeriod, new CurrencyCodeEntry[]
            {
            });

            Assert.Equal(0, data.Count);
        }
コード例 #4
0
        public void ImportPeriodicDataWhenCurrencyCodesArrayIsNull()
        {
            ICurrencyImporter importer         = new JsonCurrencyImporter();
            ICurrencyProvider currencyProvider = new NationalBankCurrencyProvider(importer);
            ICachingProcessor cachingProcessor = new ApiDatabaseCachingProcessor(currencyProvider, new MsSqlExplorerRepository(new CurrencyDataContext()));

            ChartTimePeriod timePeriod = new ChartTimePeriod(DateTime.Now.Subtract(TimeSpan.FromDays(10)), DateTime.Now);

            Action action = () =>
            {
                cachingProcessor.RequestPeriodData(timePeriod, null);
            };

            Assert.ThrowsAny <NullReferenceException>(action);
        }
コード例 #5
0
        public void ImportDataFromBankAPI()
        {
            ICurrencyImporter importer         = new JsonCurrencyImporter();
            ICurrencyProvider currencyProvider = new NationalBankCurrencyProvider(importer);

            try
            {
                var data = currencyProvider.RequestSingleCurrencyData(DateTime.Now);

                Assert.NotNull(data);
            }
            catch (Exception e)
            {
                Assert.True(e is NoItemsException);
            }
        }