コード例 #1
0
        public void TestWithMethodInputAsFunctions()
        {
            var tester  = new JsonExecutor(ReadTestFile("MethodInputAsFunctoid.json"), ReadTestFile("config.json"), msg => { });
            var results = tester.Execute(new Dictionary <string, object>()
            {
            });

            Console.WriteLine("==========================");
            foreach (var kv in results)
            {
                Console.WriteLine($"{kv.Key}  {kv.Value}");
            }
            Console.WriteLine("==========================");
        }
コード例 #2
0
        /// <summary>
        /// Executes the test.
        /// </summary>
        /// <param name="isVerify">
        /// true for verifying the results with expected one.
        /// </param>
        /// <returns>
        /// Task instance.
        /// </returns>
        public async Task Execute(bool isVerify)
        {
            await new TaskFactory().StartNew(() =>
            {
                try
                {
                    this.TraceMessages.Clear();
                    this.TestStatus = TestStatus.Running;
                    var executor    = new JsonExecutor(this.Data, this.ConfigJson, this.TraceAction);
                    if (isVerify)
                    {
                        executor.ExecuteAndVerify(this.Variables);
                        this.ResultsData = "Success";
                    }
                    else
                    {
                        var output       = executor.Execute(this.Variables);
                        this.ResultsData = JsonConvert.SerializeObject(output);
                    }

                    this.TestStatus = TestStatus.Success;
                }
                catch (AssertionFailedException ae)
                {
                    this.TestStatus  = TestStatus.Error;
                    this.ResultsData = ae.Message;      // good with message.
                }
                catch (Exception e)
                {
                    this.TestStatus  = TestStatus.Error;
                    this.ResultsData = e.ToString();
                }
                finally
                {
                    this.OnPropertyChanged(() => this.ResultsData);
                    this.OnPropertyChanged(() => this.TestStatus);
                }
            });
        }