public List<TestResult> RunTests(Setup setup, IList<Test> tests, Teardown teardown)
        {
            var results = new List<TestResult>();

            foreach (var test in tests)
            {
                var result = new TestResult();
                try
                {
                    result.TestName = test.Method.Name;
                    setup.Invoke();
                    test.Invoke();
                    result.Success = true;

                }
                catch(Exception exception)
                {
                    result.Success = false;
                    result.Result = exception.Message;
                }
                finally
                {
                    results.Add(result);
                }                
            }

            return results;
        }
        public List <TestResult> RunTests(Setup setup, IList <Test> tests, Teardown teardown)
        {
            var results = new List <TestResult>();

            foreach (var test in tests)
            {
                var result = new TestResult();
                try
                {
                    result.TestName = test.Method.Name;
                    setup.Invoke();
                    test.Invoke();
                    result.Success = true;
                }
                catch (Exception exception)
                {
                    result.Success = false;
                    result.Result  = exception.Message;
                }
                finally
                {
                    results.Add(result);
                }
            }

            return(results);
        }
Пример #3
0
        public void Stop()
        {
            cts.Cancel();
            listener?.Dispose();
            listener = null;

            Teardown?.Invoke(this, EventArgs.Empty);
        }
Пример #4
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }

            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if (Identifier != null)
            {
                writer.WritePropertyName("identifier");
                Identifier.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Name))
            {
                writer.WriteString("name", (string)Name !);
            }

            if (_Name != null)
            {
                writer.WritePropertyName("_name");
                _Name.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if (TestScript != null)
            {
                writer.WritePropertyName("testScript");
                TestScript.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Result))
            {
                writer.WriteString("result", (string)Result !);
            }

            if (_Result != null)
            {
                writer.WritePropertyName("_result");
                _Result.SerializeJson(writer, options);
            }

            if (Score != null)
            {
                writer.WriteNumber("score", (decimal)Score !);
            }

            if (_Score != null)
            {
                writer.WritePropertyName("_score");
                _Score.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Tester))
            {
                writer.WriteString("tester", (string)Tester !);
            }

            if (_Tester != null)
            {
                writer.WritePropertyName("_tester");
                _Tester.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Issued))
            {
                writer.WriteString("issued", (string)Issued !);
            }

            if (_Issued != null)
            {
                writer.WritePropertyName("_issued");
                _Issued.SerializeJson(writer, options);
            }

            if ((Participant != null) && (Participant.Count != 0))
            {
                writer.WritePropertyName("participant");
                writer.WriteStartArray();

                foreach (TestReportParticipant valParticipant in Participant)
                {
                    valParticipant.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Setup != null)
            {
                writer.WritePropertyName("setup");
                Setup.SerializeJson(writer, options);
            }

            if ((Test != null) && (Test.Count != 0))
            {
                writer.WritePropertyName("test");
                writer.WriteStartArray();

                foreach (TestReportTest valTest in Test)
                {
                    valTest.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Teardown != null)
            {
                writer.WritePropertyName("teardown");
                Teardown.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }