public static string GetCurrentTestResultStatus(ITestResultCmdletBaseDataObject cmdlet)
{
string testResultId = cmdlet.Id;
if (!string.IsNullOrEmpty(testResultId)) {
// if (null != testResultId && string.Empty != testResultId && 0 < testResultId.Length) {
// if (null != TestData.CurrentTestResult) {
// cmdlet.WriteObject(cmdlet, TestData.CurrentTestResult.Status);
// } else {
// cmdlet.WriteObject(cmdlet, "NOT TESTED");
// }
// 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;
// 20140720
// if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) return;
if (null == testResultWithIdCollection || !testResultWithIdCollection.Any()) return string.Empty;
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
// 20140720
// cmdlet.WriteObject(cmdlet, ((ITestResult)testResultWithId).Status);
return ((ITestResult)testResultWithId).Status;
}
catch {
//cmdlet.WriteObject(cmdlet, (new object[] { null }));
// 20140720
// cmdlet.WriteObject(cmdlet, "NOT TESTED");
return "NOT TESTED";
}
}
/*
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
cmdlet.WriteObject(cmdlet, ((ITestResult)testResultWithId).Status);
}
catch {
//cmdlet.WriteObject(cmdlet, (new object[] { null }));
cmdlet.WriteObject(cmdlet, "NOT TESTED");
}
}
}
*/
// 20140720
return string.Empty;
} else {
// cmdlet.WriteVerbose(cmdlet, "Trying the current test result");
// 20140720
// if (null == TestData.CurrentTestResult) return;
return null == TestData.CurrentTestResult ? string.Empty : TestData.CurrentTestResult.Status;
// cmdlet.WriteVerbose(cmdlet, "The current test result");
// 20140720
// cmdlet.WriteObject(cmdlet, TestData.CurrentTestResult.Status);
}
}