public TestMonitor(HealthCheckService service, string key, ITest test)
 {
     this.Key = key;
     this.test = test;
     this.Result = null;
     this.Events = new List<TestEvent>();
     this.cancelToken = new CancellationToken();
 }
        private TestResult RunCore()
        {
            this.Events.Clear();
            //while (this.Events.Any())
            //{
            //    TestEvent result;
            //    if (!this.Events.TryDequeue(out result))
            //    {
            //        break;
            //    }
            //}

            this.Result = null;
            this.OnStarted();

            var r = new TestResult();
            try
            {
                test.Test(this);
                r.Message = string.Empty;
                r.Success = true;
            }
            catch (PassedWithWarningException ex)
            {
                r.Message = ex.Message;
                r.ShowWarning = true;
                r.Success = true;
            }
            catch (Exception ex)
            {
                r.Message = ex.Message;
                r.Success = false;
            }
            return r;
        }
 private TestResult RunComplete(Task<TestResult> t)
 {
     this.Result = t.Result;
     this.task = null;
     this.OnCompleted();
     return t.Result;
 }