public static TestResult Get(string hudsonUri, string name, int number)
        {
            var    client = new WebClient();
            string testResultString;

            try
            {
                testResultString =
                    client.DownloadString(
                        hudsonUri + "job/" + Uri.EscapeUriString(name) + "/" + number + "/testReport/api/xml");
            }
            catch (WebException)
            {
                return(null);
            }

            TestResult testResult = null;
            var        reader     = new StringReader(testResultString);

            if (testResultString.StartsWith("<testResult>"))
            {
                testResult = new TestResult();
                var serializer = new XmlSerializer(testResult.GetType());
                testResult = (TestResult)serializer.Deserialize(reader);
            }
            else if (testResultString.StartsWith("<matrixTestResult>"))
            {
                testResult = new MatrixTestResult();
                var serializer = new XmlSerializer(testResult.GetType());
                testResult = (MatrixTestResult)serializer.Deserialize(reader);
            }
            else
            {
                var testResultType = testResultString.Substring(1, testResultString.IndexOf('>') - 1);
                throw new NotSupportedException(string.Format("Unrecognised test result type '{0}'", testResultType));
            }

            return(testResult);
        }
Exemplo n.º 2
0
        public static TestResult Get(string hudsonUri, string name, int number)
        {
            var client = new WebClient();
            string testResultString;
            try
            {
                testResultString =
                    client.DownloadString(
                        hudsonUri + "job/" + Uri.EscapeUriString(name) + "/" + number + "/testReport/api/xml");
            }
            catch (WebException)
            {
                return null;
            }

            TestResult testResult = null;
            var reader = new StringReader(testResultString);

            if (testResultString.StartsWith("<testResult>"))
            {
                testResult = new TestResult();
                var serializer = new XmlSerializer(testResult.GetType());
                testResult = (TestResult)serializer.Deserialize(reader);
            }
            else if (testResultString.StartsWith("<matrixTestResult>"))
            {
                testResult = new MatrixTestResult();
                var serializer = new XmlSerializer(testResult.GetType());
                testResult = (MatrixTestResult)serializer.Deserialize(reader);
            }
            else
            {
                var testResultType = testResultString.Substring(1, testResultString.IndexOf('>') - 1);
                throw new NotSupportedException(string.Format("Unrecognised test result type '{0}'", testResultType));
            }

            return testResult;
        }
Exemplo n.º 3
0
 public void AddPerformanceMatrixTestResultAsync(MatrixTestResult result, object userState)
 {
     if ((this.AddPerformanceMatrixTestResultOperationCompleted == null)) {
         this.AddPerformanceMatrixTestResultOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddPerformanceMatrixTestResultCompleted);
     }
     this.InvokeAsync("AddPerformanceMatrixTestResult", new object[] {
                 result}, this.AddPerformanceMatrixTestResultOperationCompleted, userState);
 }
Exemplo n.º 4
0
 public System.IAsyncResult BeginAddPerformanceMatrixTestResult(MatrixTestResult result, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("AddPerformanceMatrixTestResult", new object[] {
                 result}, callback, asyncState);
 }
Exemplo n.º 5
0
 public void AddPerformanceMatrixTestResultAsync(MatrixTestResult result)
 {
     this.AddPerformanceMatrixTestResultAsync(result, null);
 }