예제 #1
0
        public void DatabaseCacheTest_2()
        {
            DatabaseCacheTest();

            var provider    = new SQLiteDataProvider(@"..\..\..\test_database\resources\covid.db");
            var cacheSystem = new DatabaseCache();

            cacheSystem.Attach(provider);
            cacheSystem.CheckUpdate();    //check if the data is fresh (yesterday is present in the db) and update the db if not
        }
예제 #2
0
        public void DatabaseCacheTest()
        {
            var provider = new MockDatabaseProvider();

            var cacheSystem = new DatabaseCache();

            cacheSystem.Attach(provider);

            IDataProvider <CountryInfo> mockDataProvider = new MockDataProvider();

            cacheSystem.CountryInfoList = mockDataProvider.GetCountryData().ToList();

            //Extract list of countryInfoEx
            var countryInfoExList = provider.GetCountryData();

            foreach (var countryInfo in countryInfoExList)
            {
                var tuple = (countryInfo.Confirmed, countryInfo.Deaths, countryInfo.Recovered);
                switch (countryInfo.Name)
                {
                case "Italy":
                    Assert.AreEqual(tuple, (2, 0, 1));
                    break;

                case "USA":
                    Assert.AreEqual(tuple, (18, 4, 0));
                    break;

                case "Romania":
                    Assert.AreEqual(tuple, (25, 3, 1));
                    break;

                case "China":
                    Assert.AreEqual(tuple, (80, 10, 5));
                    break;
                }
            }
        }
예제 #3
0
        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
            }));
        }