public async Task DataBaseSaveCurs_Ok_Test() { IConfiguration config = SU.GetConfiguration(); ExchangeRatesDdContext dbContext = new ExchangeRatesDdContext(config, SU.GetLogger <ExchangeRatesDdContext>()); DbWorker db = new DbWorker(config, SU.GetLogger <DbWorker>(), dbContext); Valute saveValute = new Valute() { CharCode = "TEST_1", Name = "TEST_1", Nominal = 10, Value = 10.1m }; bool result = await db.StoreCurrencyAsync(new ValCurs() { Date = DateTime.Today.AddYears(-100), Name = "TEST_0", Valute = new List <Valute>() { saveValute } }); Assert.True(result); IQueryable <ExchangeRates> restoreValute = dbContext.ExchangeRates.Where(valute => valute.Name == saveValute.Name && valute.Value == saveValute.Value && saveValute.Nominal == saveValute.Nominal); Assert.True(restoreValute.Any()); dbContext.ExchangeRates.Remove(restoreValute.Single()); dbContext.SaveChanges(); }
public async Task GetRequest_Ok_Test() { WebWorker web = new WebWorker(SU.GetConfiguration(), SU.GetLogger <WebWorker>()); await using Stream response = await web.RequestNewCurrencyAsync(DateTime.Today); Assert.NotNull(response); using StreamReader responseReader = new StreamReader(response); string stringResponse = await responseReader.ReadToEndAsync(); Assert.True(stringResponse.Length > 0); }
public async Task ParseResponse_Bad_Test() { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ILogger <ResponseParser> logger = SU.GetLogger <ResponseParser>(); ResponseParser parser = new ResponseParser(logger); await using FileStream testResponse = SU.GetFileStream(@".\TestData\ResponseBad.xml"); ValCurs curs = await parser.ParseCursAsync(testResponse); Assert.Null(curs); }