示例#1
0
        public async Task TestLive()
        {
            var nbr = new GetNBRExchange();

            foreach (var e in await nbr.GetActualRates())
            {
                if (e.ExchangeFrom == "EUR")
                {
                    Assert.True(true);
                    return;
                }
            }
            Assert.True(false, "Should find EUR");
        }
示例#2
0
        public async Task TestPrevData()
        {
            var date = new DateTime(2020, 03, 11);
            var nbr  = new GetNBRExchange();

            foreach (var e in await nbr.GetPreviousRates(date))
            {
                if (e.ExchangeFrom == "EUR")
                {
                    Assert.True(true);
                    return;
                }
            }
            Assert.True(false, "Should find EUR");
        }
示例#3
0
        public async Task TestParsing()
        {
            var response = await File.ReadAllTextAsync(Path.Combine("Data", "20191020bnr.txt"));

            var m = new MockHttpMessageHandler();

            m.When("https://www.bnr.ro/nbrfxrates.xml")
            .Respond("application/text", response);

            var nbr = new GetNBRExchange(m);

            foreach (var e in await nbr.GetActualRates())
            {
                if (e.ExchangeFrom == "EUR")
                {
                    Assert.Equal(4.7572m, e.ExchangeValue, 4);
                    return;
                }
            }
            Assert.True(false, "Should find EUR");
        }
示例#4
0
        public async Task SaveAndRetrieveOne()
        {
            InMemoryDB.ResetInMemoryDatabase();
            InMemoryDB mem      = new InMemoryDB(null);
            ISave      s        = new SaveSqlServer(mem);
            var        response = await File.ReadAllTextAsync(Path.Combine("Data", "20191020bnr.txt"));

            var m = new MockHttpMessageHandler();

            m.When("https://www.bnr.ro/nbrfxrates.xml")
            .Respond("application/text", response);

            var nbr  = new GetNBRExchange(m);
            var data = (await nbr.GetActualRates()).ToArray();
            var nr   = await s.Save(data);

            var f = data[0];
            var q = new RetrieveSqlServer(mem);
            var t = await q.Rate("BNR", f.Date.Date, f.ExchangeFrom);

            Assert.Equal(f.ExchangeValue, t.ExchangeValue);
        }