public void DataProviderTest() { var provider = new SQLiteDataProvider(@"..\..\resources\covid.db"); try { provider.ClearDayInfoData(); } catch (Exception) { // ignored } //Test insertion of CountryInfo list IDataProvider <CountryInfo> mockDataProvider = new MockDataProvider(); var list = mockDataProvider.GetCountryData(); provider.InsertCountryData(list); //Extract list of countryInfoEx var countryInfoExList = provider.GetCountryData(); foreach (var countryInfo in countryInfoExList) { var tuple = (countryInfo.Confirmed, countryInfo.Deaths, countryInfo.Recovered, countryInfo.Continent, countryInfo.Population); switch (countryInfo.Name) { case "Italy": Assert.AreEqual(tuple, (2, 0, 1, "Europe", 50_000_000)); break; case "USA": Assert.AreEqual(tuple, (18, 4, 0, "America", 300_000_000)); break; case "Romania": Assert.AreEqual(tuple, (25, 3, 1, "Europe", 19_000_000)); break; case "China": Assert.AreEqual(tuple, (80, 10, 5, "Asia", 1_000_000_000)); break; } } //Test extraction the most recent date Assert.AreEqual(new Date(1983, 11, 30), provider.GetTheMostRecentDateOfData()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var provider = new SQLiteDataProvider(); var cacheSystem = new DatabaseCache(); cacheSystem.Attach(provider); cacheSystem.CheckUpdate(); //check if the data is fresh (yesterday is present in the db) var data = provider.GetCountryData(); MapView mapView = new MapView(data); IView globalView = new GlobalView(data); CountryView countryView = new CountryView(data); mapView.Subscribe(countryView); Application.Run(new MainForm(new List <IView> { mapView, globalView, countryView })); }