예제 #1
0
        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;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 // DELETE api/Rates/5
 public void Delete(int id)
 {
     RatesRepository.Delete(id);
 }
예제 #8
0
 // PUT api/Rates/5
 public void Put(int id, [FromBody] Rate value)
 {
     RatesRepository.Update(value);
 }
예제 #9
0
 // POST api/Rates
 public void Post([FromBody] Rate value)
 {
     RatesRepository.Insert(value);
 }
예제 #10
0
 // GET api/Rates/5
 public Rate Get(int id)
 {
     return(RatesRepository.GetById(id));
 }
예제 #11
0
 // GET api/Rate
 public IEnumerable <Rate> Get()
 {
     return(RatesRepository.GetAll());
 }
예제 #12
0
 [TestInitialize] public override void TestInitialize()
 {
     base.TestInitialize();
     type  = typeof(RatesRepository);
     rates = repository as RatesRepository;
 }
예제 #13
0
 public App()
 {
     Rates           = new RatesViewModel();
     ratesRepository = new RatesRepository();
     MainPage        = new NavigationPage(new OpenRates.RatesPage());
 }