public string Get(string startDate, string endDate) { var logStartTime = DateTime.Now; DateTime start; DateTime end; if (!DateTime.TryParse(startDate, null, System.Globalization.DateTimeStyles.RoundtripKind, out start)) { throw new ArgumentException($"Could not parse ${nameof(startDate)}: {startDate} into a DateTime"); } if (!DateTime.TryParse(endDate, null, System.Globalization.DateTimeStyles.RoundtripKind, out end)) { throw new ArgumentException($"Could not parse ${nameof(endDate)}: {endDate} into a DateTime"); } var logEndTime = DateTime.Now; var rate = RatesRepository.GetRateForTimePeriod(start, end)?.Price.ToString() ?? "NOT AVAILABLE"; StatisticsRepository.LogTime($"api/rates", (logEndTime - logStartTime).TotalSeconds); return(rate); }
public override void TestInitialize() { base.TestInitialize(); repository = new RatesRepository(db); controller = "rates"; detailsViewCaption = "Exchange Rate"; editViewCaption = detailsViewCaption; }
public async Task <IEnumerable <Candle> > Hello(Request request) { var ratesRepository = new RatesRepository(); var candles = await ratesRepository.GetDailyRates(request.Coin, request.Days); Console.WriteLine("Serverless testing"); return(candles); }
public void Rates_Repository_CalculateCost_ShouldBeCorrectDecimal() { RatesRepository _ratesRepo = new RatesRepository(); Cost cost = Cost.basePremium; decimal actual = _ratesRepo.CalculateCost(cost); decimal expected = 75m; Assert.AreEqual(expected, actual); }
public async Task <IEnumerable <Candle> > Daily(int days) { var ratesRepository = new RatesRepository(); var candles = new List <Candle>(); candles.AddRange(await ratesRepository.GetDailyRates(Coin.BTC, days)); candles.AddRange(await ratesRepository.GetDailyRates(Coin.ETH, days)); candles.AddRange(await ratesRepository.GetDailyRates(Coin.LTC, days)); return(candles); }
public async Task DeleteCorrecto() { var rate = new Rates { From = "EUR", To = "USD", Rate = 1.359m }; var repositorio = new RatesRepository(); repositorio.Insert(rate); await repositorio.Delete(rate.Id); await repositorio.Save(); var rateGuardado = await repositorio.GetById(rate.Id); Assert.IsNull(rateGuardado); }
// DELETE api/Rates/5 public void Delete(int id) { RatesRepository.Delete(id); }
// PUT api/Rates/5 public void Put(int id, [FromBody] Rate value) { RatesRepository.Update(value); }
// POST api/Rates public void Post([FromBody] Rate value) { RatesRepository.Insert(value); }
// GET api/Rates/5 public Rate Get(int id) { return(RatesRepository.GetById(id)); }
// GET api/Rate public IEnumerable <Rate> Get() { return(RatesRepository.GetAll()); }
[TestInitialize] public override void TestInitialize() { base.TestInitialize(); type = typeof(RatesRepository); rates = repository as RatesRepository; }
public App() { Rates = new RatesViewModel(); ratesRepository = new RatesRepository(); MainPage = new NavigationPage(new OpenRates.RatesPage()); }