Beispiel #1
0
        public void TestEarthquakeInformationCount()
        {
            var earthquakeInformation = new EarthquakeInformation();
            var earthquakeInstances   = earthquakeInformation.EarthquakeInstances;

            Assert.IsTrue(earthquakeInstances.Count() > 0);
        }
Beispiel #2
0
        public void TestEarthquakeInformationLatestSyncTime()
        {
            var earthquakeInformation = new EarthquakeInformation();
            var latestSyncTime        = earthquakeInformation.LatestSyncTime;

            Assert.IsNotNull(latestSyncTime);
        }
        /// <summary>
        /// ViewModel constructor initializes the model to obtain earthquake information.
        /// This also requests the model to monitor for realtime earthquake information. The model does
        /// a call back periodically when the information is obtained so that the view can update.
        /// </summary>
        public EarthquakeMonitorViewModel()
        {
            try
            {
                EarthquakeInformationTitle = Properties.Settings.Default.EarthquakeInformationTitle;

                // Instantiate the model class.
                EarthquakeInformation = new EarthquakeInformation();

                if (EarthquakeInformation != null)
                {
                    // Obtain the information about earthquakes in the last time span (e.g 1 hour).
                    // Initialize the observable collection which notifies the view.
                    EarthquakeInstances = new ObservableCollection <IEarthquakeInstance>(EarthquakeInformation.EarthquakeInstances);

                    // Get the time at which the earthquake information was requested.
                    EarthquakeInstancesSyncTime = EarthquakeInformation.LatestSyncTime;
                }
                else
                {
                    EarthquakeInstances = new ObservableCollection <IEarthquakeInstance>();
                }
            }
            catch (Exception)
            {
                EarthquakeInformationTitle = "Unable to obtain earthquake information.";
            }

            try
            {
                // Request model to periodically monitor for updated earthquake information.
                // The method call back is passed in as the parameter.
                if (Properties.Settings.Default.EarthquakeInformationContinousMonitoring)
                {
                    EarthquakeInformation.Monitor(UpdateEarthquakeInformation);
                }
            }
            catch (Exception)
            {
                EarthquakeInformationTitle = "Unable to obtain realtime earthquake information.";
            }
        }