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"); }
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"); }
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"); }
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); }