Exemplo n.º 1
0
        public TestResultData GetTestCache(string id, [FromUri] TestSourceData testSourceData)
        {
            TestResult testResult;

            var buildSource = new BuildSource(testSourceData.MachineName, testSourceData.EnlistmentRoot);
            var isJenkins   = string.IsNullOrEmpty(testSourceData.Source)
                ? null
                : (bool?)(testSourceData.Source == "jenkins");

            if (_storage.TryGetValue(id, out testResult))
            {
                var isJenkinsValue = isJenkins ?? false;
                _statsUtil.AddHit(isJenkinsValue);
                _statsUtil.AddUnitTestQuery(testResult.UnitTestData, testResult.Elapsed, isJenkinsValue);

                var testResultData = new TestResultData()
                {
                    ExitCode           = testResult.ExitCode,
                    OutputStandard     = testResult.OutputStandard,
                    OutputError        = testResult.OutputError,
                    ResultsFileName    = testResult.ResultsFileName,
                    ResultsFileContent = testResult.ResultsFileContent,
                    ElapsedSeconds     = (int)testResult.Elapsed.TotalSeconds
                };
                return(testResultData);
            }

            _statsUtil.AddMiss(isJenkins ?? false);
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
Exemplo n.º 2
0
        public ActionResult Result(string id)
        {
            Azure.TestResult testResult;
            if (!_testResultStorage.TryGetValue(id, out testResult))
            {
                throw new Exception("Invalid key");
            }

            var contentType = testResult.ResultsFileName.EndsWith("xml")
                ? "application/xml"
                : "text/html";

            return(Content(testResult.ResultsFileContent, contentType));
        }