Ejemplo n.º 1
0
        public static void GetCurrentTestResultStatus(TestResultCmdletBase cmdlet)
        {
            // 20130403
            string testResultId = cmdlet.Id;

            cmdlet.WriteVerbose(cmdlet, "Getting test result with Id = " + 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;

                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");
                        }
                    }
                }

            } 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.Status);
                }

            }
        }
Ejemplo n.º 2
0
        public static void SetCurrentTestResult(TestResultCmdletBase cmdlet)
        {
            if (null != TestData.CurrentTestResult) {

                if (null != cmdlet.TestResultName && 0 < cmdlet.TestResultName.Length) {

                    TestData.CurrentTestResult.Name = cmdlet.TestResultName;
                } else {

                    TestData.CurrentTestResult.Name = "this test result was preset";
                }

                if (null != cmdlet.Id && 0 < cmdlet.Id.Length) {

                    TestData.CurrentTestResult.Id = cmdlet.Id;
                } else {

                    TestData.GetTestResultId();
                }

                if (null != cmdlet.Description && 0 < cmdlet.Description.Length) {

                    TestData.CurrentTestResult.Description = cmdlet.Description;
                }

                // 20130330
                //TestData.CurrentTestResult.enStatus = TestResultStatuses.Failed;
                TestData.CurrentTestResult.enStatus = TestResultStatuses.NotTested;

                if (cmdlet.KnownIssue) {

                    TestData.CurrentTestResult.enStatus = TestResultStatuses.KnownIssue;
                }

                // 20130627
                //TestData.CurrentTestResult.SetOrigin(TestResultOrigins.Logical);
                TestData.CurrentTestResult.SetOrigin(cmdlet.TestOrigin);

            } else {

                // there always is the current test result
            }
        }