Question: Write a junit test for the following test code: using System; using Xamarin.Forms; namespace Covid19Radar.Common { public class HoursTimer { public delegate void TimeOutHandler(EventArgs e);
Write a junit test for the following test code: using System; using Xamarin.Forms; namespace Covid19Radar.Common { public class HoursTimer { public delegate void TimeOutHandler(EventArgs e); public event TimeOutHandler TimeOutEvent; private DateTime _startDateTime; private bool _timerRunning; private int _timeDiffernce; public HoursTimer(int timeDiffernce) { _timeDiffernce = timeDiffernce; this._timerRunning = false; } public void Start() { if (this._timerRunning == true) return; RegisterTimer(this.HandleFunc); } public void Stop() { this._timerRunning = false; } private bool HandleFunc() { if (this._timerRunning == true) { if (this.TimeOutEvent != null) { Device.BeginInvokeOnMainThread(() => { this.TimeOutEvent(new EventArgs()); }); } RegisterTimer(this.HandleFunc); } return false; } private void RegisterTimer(Func callback) { this._startDateTime = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, 0); double spanMinutes = 60 - this._startDateTime.Minute + _timeDiffernce; this._timerRunning = true; Device.StartTimer(TimeSpan.FromMinutes(spanMinutes), callback); } } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
