示例#1
0
        public static void GetTestResultDetails(TestResultStatusCmdletBase cmdlet)
        {
            // 20130402
            string testResultId = cmdlet.Id;

            cmdlet.WriteVerbose(cmdlet, "Getting test result with Id = " + testResultId);

            if (null != testResultId && string.Empty != testResultId && 0 < testResultId.Length) {

                cmdlet.WriteVerbose(cmdlet, "Trying to get a test result with Id = " + testResultId);

                var testResultWithIdCollection =
                    from testResult in TestData.CurrentTestScenario.TestResults
                    where testResult.Id == testResultId
                    select testResult;

                if (null != testResultWithIdCollection  && 0 < testResultWithIdCollection.Count()) {

                    foreach (ITestResult testResultWithId in testResultWithIdCollection) {

                        cmdlet.WriteVerbose(cmdlet, "Trying the test result '" + ((ITestResult)testResultWithId).Name + "'");
                        try {
                            // if the result is null, there's the try-catch construction
                            //cmdlet.WriteObject(cmdlet, ((ITestResult)testResultWithId).ListDetailNames(cmdlet));
                            foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet)) {
                                cmdlet.WriteObject(cmdlet, singleDetail.Name);
                            }
                        }
                        catch {
                            cmdlet.WriteObject(cmdlet, (new object[] { null }));
                        }
                    }
                }

            } else {

                cmdlet.WriteVerbose(cmdlet, "Trying the current test result");

                if (null != TestData.CurrentTestResult) {

                    cmdlet.WriteVerbose(cmdlet, "The current test result");
                    cmdlet.WriteObject(cmdlet, TestData.CurrentTestResult.ListDetailNames(cmdlet));
                }
            }
        }
示例#2
0
        public virtual object[] ListDetailNames(TestResultStatusCmdletBase cmdlet)
        {
            //ArrayList detailsList =
            //    new ArrayList();

            // 20130402
            ITestResultDetail[] detailsList = null;

            cmdlet.WriteVerbose(cmdlet, "trying to enumerate details");

            if (null != this.Details && 0 < this.Details.Count) {

                // 20130402
                //if (null == cmdlet.TestResultStatus) {
                if (TestResultStatuses.NotTested == cmdlet.TestResultStatus) {

                    var testResultDetailsNonFiltered =
                        from detail in this.Details
                        select detail;

                    try {
                        detailsList = testResultDetailsNonFiltered.ToArray();
                    }
                    catch {}

                } else {

                    var testResultDetailFiltered =
                        from detail in this.Details
                        where detail.DetailStatus == TestResultStatuses.Failed || detail.DetailStatus == TestResultStatuses.KnownIssue
                        select detail;

                    try {
                        detailsList = testResultDetailFiltered.ToArray();
                    }
                    catch {}

                }

            //                foreach (TestResultDetail detail in this.Details) {
            //
            //                    detailsList.Add(detail.Name);
            //                }

            }

            // 20130402
            //return detailsList.ToArray();
            return detailsList;
        }