示例#1
0
        private IDictionary <string, string> InternalGetAvailableMethods()
        {
            var testDataJson = File.ReadAllText(this._testFileName);
            var configJson   = File.ReadAllText(this._configFile);
            var executor     = new Framework.JsonExecutor(testDataJson, configJson, track => { });

            return(executor.AvailableMethods.ToDictionary(k => k.Key, k => k.Key));
        }
示例#2
0
        private TestResult InternalExecute(IDictionary <string, object> runtimeVariables, bool verboseOptions)
        {
            var traceList = new List <string>();

            try
            {
                var ret           = false;
                var testDataJson  = File.ReadAllText(this._testFileName);
                var configJson    = File.ReadAllText(this._configFile);
                var fileVariables = JsonConvert.DeserializeObject <IDictionary <string, object> >(File.ReadAllText(this._variablesFile));

                // override with incoming variables
                foreach (var kv in runtimeVariables)
                {
                    fileVariables[kv.Key] = kv.Value;
                }

                var executor = new Framework.JsonExecutor(testDataJson, configJson, track =>
                {
                    try
                    {
                        traceList.Add(JsonConvert.SerializeObject(track));
                    }
                    catch (JsonSerializationException e)
                    {
                        TraceLogger.Warning($"[Exception:{e} While serializing trace.");
                    }

                    if (verboseOptions)
                    {
                        System.Console.WriteLine(track.TraceType);
                        System.Console.WriteLine(track.TestInfo?.Name);
                        System.Console.WriteLine(track.TestInfo?.Api);
                        System.Console.WriteLine(track.MethodName);
                        System.Console.WriteLine(track.MethodReturnValue);
                        System.Console.WriteLine(track.MethodException);
                    }
                });

                executor.ExecuteAndVerify(fileVariables);
                return(new TestResult(this.TestName, true, "Success", traceList));
            }
            catch (Exception e)
            {
                if (verboseOptions)
                {
                    if (e.InnerException != null)
                    {
                        System.Console.WriteLine(e.ToString());
                    }

                    System.Console.WriteLine(e.ToString());
                }

                return(new TestResult(this.TestName, false, e.ToString(), traceList));
            }
        }