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); } }
#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. public async void WorkCorrectlyWithIncorrectDate() #pragma warning restore CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. { // Arrange JsonCurrencyImporter currencyImporter = new JsonCurrencyImporter(); // Act //var data = await currencyImporter.ImportAsync(DateTime.Parse("1900.03.10")); // Assert //Assert.Null(data); }
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); }
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); }
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); }
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); } }
public void IncorrectDateForBankApi2() { // Arrange JsonCurrencyImporter currencyImporter = new JsonCurrencyImporter(); // Act try { var data = currencyImporter.Import(DateTime.Parse("2621.03.25")); Assert.Null(data); } catch (Exception e) { Assert.True(e is NoItemsException); } }
public void ReturnNotNullJsonData() { // Arrange JsonCurrencyImporter currencyImporter = new JsonCurrencyImporter(); try { // Act var data = currencyImporter.Import(DateTime.Now); // Assert Assert.NotEqual(data, null); } catch (Exception e) { Assert.True(e is NoItemsException); } }