Beispiel #1
0
        public void WhenConvertTestcasesToTestResultObjectPreparedForJsonConverter()
        {            
            var testResultForwarder = new TestResultForwarder() { XMLResult = inputXML, Logger = TR.AppServer.Logging.Logger.Default };
            var testResult = new TestResult
            {
                Product = TestResultForwarder.ProductName,
                TimeStamp = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.000Z"),
                UUID = "dummy",
                InstallGuid = "00000000-0000-0000-0000-000000000000",
                MachineGUID = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":machineID")),
                Stats = testResultForwarder.GetTestCaseListFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":testCases//", TRRConstant.ElementPrefix, ":testCase"))
            };
            var product = TestResultForwarder.ProductName;
            var productName = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":product/@name"));            
            var productVersion = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":product/@version"));
            if (TestResultForwarder.IsEWM(productName, productVersion))
            {
                product = "ewm";
                testResultForwarder.MapStatCodeEWM(testResult);
            }
            var runningMode = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":runningMode"));
            var xnav = inputXML.CreateNavigator();
            var total = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase)", NamespaceMgr));
            var totalPass = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='pass'])", NamespaceMgr));
            var totalInfo = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='info'])", NamespaceMgr));
            var totalWarning = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='warning'])", NamespaceMgr));
            var totalAlert = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='alert'])", NamespaceMgr));
            var totalFail = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='fail'])", NamespaceMgr));
            var other = total - totalPass - totalInfo - totalWarning - totalAlert - totalFail;        

            testResult.Stats.Add(new TestCase { StatName = "runmode", StatVal = runningMode });
            testResult.Stats.Add(new TestCase { StatName = "total", StatVal = total.ToString() });
            testResult.Stats.Add(new TestCase { StatName = "pass", StatVal = totalPass.ToString() });
            testResult.Stats.Add(new TestCase { StatName = "info", StatVal = totalInfo.ToString() });
            testResultForwarder.AddValidationStat(xnav, testResult, "warn", totalWarning);
            testResultForwarder.AddValidationStat(xnav, testResult, "alert", totalAlert);
            testResultForwarder.AddValidationStat(xnav, testResult, "fail", totalFail);
            testResult.Stats.Add(new TestCase { StatName = "other", StatVal = other.ToString() });

            var compName = Environment.GetEnvironmentVariable("COMPUTERNAME") ?? "";
            var envName = Environment.GetEnvironmentVariable("AS_ENV") ?? "";

            testResult.Stats.Add(new TestCase { StatName = "servname", StatVal = compName });
            testResult.Stats.Add(new TestCase { StatName = "envname", StatVal = envName });
            //testResult.Stats.Add(new TestCase { StatName = "testID", StatVal = testID });
            testResult.Stats.Add(new TestCase { StatName = "product", StatVal = product });            

            ScenarioContext.Current.Set(testResult, "testResult");
        }