public void GetExchangeRates_WrongParsingXml_ThrowException() { var fetcher = Substitute.For <IExchangeService>(); var logger = Substitute.For <ILogger>(); ExchangeFetcher ex = new ExchangeFetcher(fetcher, logger); ex.GetExchangeRates("<MyTestElement/>"); logger.Received().LogMessage("Couldnt parse xml document"); }
public void GetExchangeRates_IsNotValidServiceUriForLoadingXml_LogExceptionForXML() { var fakefetcher = Substitute.For <IExchangeService>(); var logger = Substitute.For <ILogger>(); fakefetcher.When(x => x.LoadXMLData(Arg.Any <string>())).Do( info => { throw new Exception("fake exception"); }); ExchangeFetcher ex = new ExchangeFetcher(fakefetcher, logger); ex.GetExchangeRates("http://www.tcmb.gov.tr/kurlar/today.xml"); logger.Received().LogMessage("Null returned while reading xml file"); }
public void FetchRates() { string connectionString = ConfigurationManager.ConnectionStrings["ApplicationDbEntities"].ConnectionString; SqlServerDataAccess.SqlCurrencyRepository repository = new SqlServerDataAccess.SqlCurrencyRepository(connectionString); string serviceUri = "http://www.tcmb.gov.tr/kurlar/today.xml"; ExchangeFetcher fetcher = new ExchangeFetcher(); var parsedlist = fetcher.GetExchangeRates(serviceUri); CurrencyService cs = new GkfxDomain.CurrencyService(repository); cs.UpdateInsertExchangeRates(parsedlist); Console.WriteLine("Exchange Rates Populated to Database : " + DateTime.Now.ToString()); }
public void LoadData_IsNotValidServiceUri_ReturnNull() { ExchangeFetcher fetcher = new ExchangeFetcher(); Assert.IsNull(fetcher.LoadData()); }
public void GetExchangeRates_IsNotValidServiceUri_ThrowsException() { ExchangeFetcher fetcher = new ExchangeFetcher(); fetcher.GetExchangeRates(string.Empty); }
public void GetExchangeRates_IsValidServiceUri_ReturnData() { ExchangeFetcher fetcher = new ExchangeFetcher(); Assert.IsNotNull(fetcher.GetExchangeRates("http://www.tcmb.gov.tr/kurlar/today.xml")); }