public static object[] GetTestResultDetails(ITestResultStatusCmdletBaseDataObject cmdlet) { string testResultId = cmdlet.Id; if (!string.IsNullOrEmpty(testResultId)) { var testResultWithIdCollection = from testResult in TestData.CurrentTestScenario.TestResults where testResult.Id == testResultId select testResult; // 20140720 // if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) return; if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) { return new[] { string.Empty } } ; foreach (ITestResult testResultWithId in testResultWithIdCollection) { try { // if the result is null, there's the try-catch construction // 20140703 // refactoring // foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet)) { foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet.TestResultStatus)) { // 20140720 // cmdlet.WriteObject(cmdlet, singleDetail.Name); return(new[] { singleDetail.Name }); } } catch { // 20140720 // cmdlet.WriteObject(cmdlet, (new object[] { null })); return(new object[] { null }); } } /* * if (null != testResultWithIdCollection && testResultWithIdCollection.Any()) { * // 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 * foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet)) { * cmdlet.WriteObject(cmdlet, singleDetail.Name); * } * } * catch { * cmdlet.WriteObject(cmdlet, (new object[] { null })); * } * } * } */ // 20140720 return(new[] { string.Empty }); } else { // 20140720 // if (null == TestData.CurrentTestResult) return; return(null == TestData.CurrentTestResult ? new[] { string.Empty } : TestData.CurrentTestResult.ListDetailNames(cmdlet.TestResultStatus)); // cmdlet.WriteVerbose(cmdlet, "The current test result"); // 20140720 // cmdlet.WriteObject(cmdlet, TestData.CurrentTestResult.ListDetailNames(cmdlet.TestResultStatus)); } }
public static object[] GetTestResultDetails(ITestResultStatusCmdletBaseDataObject cmdlet) { string testResultId = cmdlet.Id; if (!string.IsNullOrEmpty(testResultId)) { var testResultWithIdCollection = from testResult in TestData.CurrentTestScenario.TestResults where testResult.Id == testResultId select testResult; // 20140720 // if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) return; if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) return new[] { string.Empty }; foreach (ITestResult testResultWithId in testResultWithIdCollection) { try { // if the result is null, there's the try-catch construction // 20140703 // refactoring // foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet)) { foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet.TestResultStatus)) { // 20140720 // cmdlet.WriteObject(cmdlet, singleDetail.Name); return new[] { singleDetail.Name }; } } catch { // 20140720 // cmdlet.WriteObject(cmdlet, (new object[] { null })); return new object[] { null }; } } /* if (null != testResultWithIdCollection && testResultWithIdCollection.Any()) { // 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 foreach (ITestResultDetail singleDetail in ((ITestResult)testResultWithId).ListDetailNames(cmdlet)) { cmdlet.WriteObject(cmdlet, singleDetail.Name); } } catch { cmdlet.WriteObject(cmdlet, (new object[] { null })); } } } */ // 20140720 return new[] { string.Empty }; } else { // 20140720 // if (null == TestData.CurrentTestResult) return; return null == TestData.CurrentTestResult ? new[] { string.Empty } : TestData.CurrentTestResult.ListDetailNames(cmdlet.TestResultStatus); // cmdlet.WriteVerbose(cmdlet, "The current test result"); // 20140720 // cmdlet.WriteObject(cmdlet, TestData.CurrentTestResult.ListDetailNames(cmdlet.TestResultStatus)); } }