internal override void Execute() { var cmdlet = (SetTmxCurrentTestResultCommand)Cmdlet; cmdlet.ConvertTestResultStatusToTraditionalTestResult(); cmdlet.WriteVerbose( cmdlet, "Checking the current test structure, creating the first test suite and scenario if needed"); TestData.InitCurrentTestScenario(); cmdlet.WriteVerbose( cmdlet, "Checking whether the current test result is fulfilled and must be added to the current test scenario's results"); if (null != TestData.CurrentTestResult) { cmdlet.WriteVerbose( cmdlet, "The current test result is not null"); if (!string.IsNullOrEmpty(TestData.CurrentTestResult.Name) || (0 < TestData.CurrentTestResult.Details.Count)) { cmdlet.WriteVerbose( cmdlet, "Adding the current test result to the current test scenario's results"); TestData.CurrentTestResult.SetTimeSpent( //(TestData.CurrentTestResult.Timestamp - TmxHelper.TestCaseStarted).TotalSeconds); //(System.DateTime.Now - TmxHelper.TestCaseStarted).TotalSeconds); (DateTime.Now - TestData.CurrentTestResult.Timestamp).TotalSeconds); cmdlet.WriteVerbose( cmdlet, "Finishing test result Id = '" + TestData.CurrentTestResult.Id + "' Name = '" + TestData.CurrentTestResult.Name + "' Status = '" + TestData.CurrentTestResult.Status + "' TimeSpent = " + TestData.CurrentTestResult.TimeSpent.ToString() + " seconds"); TmxHelper.TestCaseStarted = DateTime.Now; TestData.CurrentTestScenario.TestResults.Add(new TestResult(TestData.CurrentTestScenario.Id, TestData.CurrentTestSuite.Id)); TestData.CurrentTestScenario.TestResults[TestData.CurrentTestScenario.TestResults.Count - 1] = TestData.CurrentTestResult; } else { // nothing to do } } else { // nothing to do } cmdlet.WriteVerbose( cmdlet, "Creating the current test result for putting new data into it"); TestData.CurrentTestResult = new TestResult( TestData.CurrentTestScenario.Id, TestData.CurrentTestSuite.Id); if (string.IsNullOrEmpty(TestData.CurrentTestResult.Id)) { if (!string.IsNullOrEmpty(cmdlet.Id)) { TestData.CurrentTestResult.Id = cmdlet.Id; } else { cmdlet.WriteVerbose(cmdlet, "generating new test result Id for test result '" + TestData.CurrentTestResult.Name + "'"); TestData.CurrentTestResult.Id = TestData.GetTestResultId(); } } try { // 20141119 // TestData.CurrentTestResult.PlatformId = TestData.CurrentTestResult.PlatformUniqueId = // 20141114 // TestData.CurrentTestPlatform.Id; TestData.TestPlatforms.FirstOrDefault(tp => tp.Id == TestData.CurrentTestPlatform.Id).UniqueId; } catch {} cmdlet.WriteVerbose( cmdlet, "Writing data to the current test result"); // 20140720 // TmxHelper.SetCurrentTestResult(cmdlet); TmxHelper.SetCurrentTestResult( new TestResultCmdletBaseDataObject { TestResultName = cmdlet.TestResultName, Id = cmdlet.Id, Description = cmdlet.Description, KnownIssue = cmdlet.KnownIssue, TestOrigin = cmdlet.TestOrigin }); TestData.SetScenarioStatus(true); // skipAutomatic TestData.SetSuiteStatus(true); // skipAutomatic try { TestData.OnTmxNewTestResultClosed( TestData.CurrentTestScenario.TestResults[TestData.CurrentTestScenario.TestResults.Count - 1], null); } catch {} }
internal override void Execute() { var cmdlet = (GetTmxTestSuiteStatusCommand)Cmdlet; // 20150408 // as no longer in use /* * // 20140721 * var dataObject = new GetTmxTestSuiteStatusDataObject { * FilterOutAutomaticResults = cmdlet.FilterOutAutomaticResults, * Name = cmdlet.Name, * Id = cmdlet.Id, * TestPlatformId = cmdlet.TestPlatformId * }; */ // 20150408 var currentTestPlatform = TestData.TestPlatforms.FirstOrDefault(tp => tp.Id == cmdlet.TestPlatformId); if (null == currentTestPlatform) { cmdlet.WriteError( cmdlet, "Failed to find test suite with name = '" + cmdlet.Name + "' and id = '" + cmdlet.Id + "'", "FailedToFindTestSuite", ErrorCategory.InvalidArgument, true); } if (!string.IsNullOrEmpty(cmdlet.Name)) { // 20140721 // 20140722 var result = TmxHelper.GetTestSuiteStatusByName( // cmdlet, // dataObject, cmdlet.Name, // 20141114 // cmdlet.TestPlatformId, // 20150408 // TestData.TestPlatforms.FirstOrDefault(tp => tp.Id == cmdlet.TestPlatformId).UniqueId, currentTestPlatform.UniqueId, cmdlet.FilterOutAutomaticResults); cmdlet.WriteObject(result); } else if (!string.IsNullOrEmpty(cmdlet.Id)) { // 20140721 // 20140722 var result2 = TmxHelper.GetTestSuiteStatusById( // cmdlet, // dataObject, cmdlet.Id, // 20141114 // cmdlet.TestPlatformId, // 20150408 // TestData.TestPlatforms.FirstOrDefault(tp => tp.Id == cmdlet.TestPlatformId).UniqueId, currentTestPlatform.UniqueId, cmdlet.FilterOutAutomaticResults); cmdlet.WriteObject(result2); } else { cmdlet.WriteError( cmdlet, "Failed to find test suite with name = '" + cmdlet.Name + "' and id = '" + cmdlet.Id + "'", "FailedToFindTestSuite", ErrorCategory.InvalidArgument, true); } }
internal override void Execute() { var cmdlet = (AddScenarioCmdletBase)Cmdlet; // 20141112 var testPlatformId = cmdlet.TestPlatformId; if (string.IsNullOrEmpty(testPlatformId)) { // 20141114 // if (null == cmdlet.InputObject || string.IsNullOrEmpty(cmdlet.InputObject.PlatformId)) // 20141119 // if (null == cmdlet.InputObject || Guid.Empty == cmdlet.InputObject.PlatformId) // 20141121 ITestPlatform testPlatform = null; if (null == cmdlet.InputObject || Guid.Empty == cmdlet.InputObject.PlatformUniqueId) { // 20141114 // testPlatformId = TestData.CurrentTestSuite.PlatformId; // 20141119 // testPlatformId = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == TestData.CurrentTestSuite.PlatformId).Id; // 20141121 // testPlatformId = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == TestData.CurrentTestSuite.PlatformUniqueId).Id; testPlatform = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == TestData.CurrentTestSuite.PlatformUniqueId); } else { // 20141114 // testPlatformId = cmdlet.InputObject.PlatformId; // 20141119 // testPlatformId = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == cmdlet.InputObject.PlatformId).Id; // 20141121 // testPlatformId = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == cmdlet.InputObject.PlatformUniqueId).Id; testPlatform = TestData.TestPlatforms.FirstOrDefault(tp => tp.UniqueId == cmdlet.InputObject.PlatformUniqueId); } // 20140721 var dataObject = new AddScenarioCmdletBaseDataObject { // 20141211 // AfterTest = cmdlet.AfterTest, // BeforeTest = cmdlet.BeforeTest, AfterTest = cmdlet.AfterTest.Select(scriptblock => new CodeBlock { Code = scriptblock.ToString() }).ToArray(), BeforeTest = cmdlet.BeforeTest.Select(scriptblock => new CodeBlock { Code = scriptblock.ToString() }).ToArray(), Description = cmdlet.Description, Id = cmdlet.Id, InputObject = cmdlet.InputObject, Name = cmdlet.Name, // 20141112 // TestPlatformId = cmdlet.TestPlatformId, // TestPlatformId = string.IsNullOrEmpty(cmdlet.TestPlatformId) ? (stri cmdlet.InputObject.PlatformId) : cmdlet.TestPlatformId, // 20141121 // TestPlatformId = testPlatformId, TestPlatformId = testPlatform.Id, TestPlatformUniqueId = testPlatform.UniqueId, TestSuiteId = cmdlet.TestSuiteId, // 20141122 // TestSuiteUniqueId = null != cmdlet.InputObject ? cmdlet.InputObject.UniqueId : TestData.CurrentTestSuite.UniqueId, TestSuiteName = cmdlet.TestSuiteName }; // bool result = TmxHelper.AddTestScenario(cmdlet); bool result = TmxHelper.AddTestScenario(dataObject); if (result) { cmdlet.WriteObject( cmdlet, TestData.CurrentTestScenario); } else { cmdlet.WriteError( cmdlet, "Couldn't add a test scenario", "AddingTestScenario", ErrorCategory.InvalidArgument, true); } } }