Negotiator CreateNewTestRun(ITestRunCommand testRunCommand) { var testRunCollectionMethods = ServerObjectFactory.Resolve<TestRunCollectionMethods>(); return !testRunCollectionMethods.SetTestRunDataAndCreateTestRun(testRunCommand, Request.Form) ? Negotiate.WithStatusCode(HttpStatusCode.ExpectationFailed).WithReasonPhrase(ServerLibrary.ReasonPhrase_TestRunsModule_FailedToCreateTestRun) : GetTestRunCollectionExpandoObject(testRunCollectionMethods.CurrentTestRunId); }
Negotiator CreateNewTestRun(ITestRunCommand testRunCommand) { var testRunCollectionMethods = ServerObjectFactory.Resolve<TestRunCollectionMethods>(); return !testRunCollectionMethods.SetTestRunDataAndCreateTestRun(testRunCommand, Request.Form) ? Negotiate.WithStatusCode(HttpStatusCode.ExpectationFailed).WithReasonPhrase("Failed to create a test run") : GetTestRunCollectionExpandoObject(); }
Negotiator CreateNewTestRun(ITestRunCommand testRunCommand) { var testRunCollectionMethods = ServerObjectFactory.Resolve <TestRunCollectionMethods>(); return(!testRunCollectionMethods.SetTestRunDataAndCreateTestRun(testRunCommand, Request.Form) ? Negotiate.WithStatusCode(HttpStatusCode.ExpectationFailed).WithReasonPhrase(ServerLibrary.ReasonPhrase_TestRunsModule_FailedToCreateTestRun) : GetTestRunCollectionExpandoObject(testRunCollectionMethods.CurrentTestRunId)); }
public bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { if (null == testRunCommand) testRunCommand = new TestRunCommand { TestRunName = formData["test_run_name"] ?? string.Empty, WorkflowName = formData["workflow_name"] ?? string.Empty }; if (string.IsNullOrEmpty(testRunCommand.WorkflowName)) testRunCommand.WorkflowName = formData["workflow_name"] ?? string.Empty; if (string.IsNullOrEmpty(testRunCommand.TestRunName)) testRunCommand.TestRunName = formData["test_run_name"] ?? string.Empty; return PrepareTestRun(testRunCommand, formData); }
public virtual bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { CurrentTestRunId = Guid.Empty; if (null == testRunCommand) testRunCommand = new TestRunCommand { TestRunName = formData[Tmx_Core_Resources.TestRunCommand_testRunName_param] ?? string.Empty, WorkflowName = formData[Tmx_Core_Resources.TestRunCommand_workflowName_param] ?? string.Empty }; if (string.IsNullOrEmpty(testRunCommand.WorkflowName)) testRunCommand.WorkflowName = formData[Tmx_Core_Resources.TestRunCommand_workflowName_param] ?? string.Empty; if (string.IsNullOrEmpty(testRunCommand.TestRunName)) testRunCommand.TestRunName = formData[Tmx_Core_Resources.TestRunCommand_testRunName_param] ?? string.Empty; return PrepareTestRun(testRunCommand, formData); }
public ITestRun CreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { if (string.IsNullOrEmpty(testRunCommand.TestRunName)) testRunCommand.TestRunName = testRunCommand.WorkflowName + " " + DateTime.Now; var testRun = new TestRun { Name = testRunCommand.TestRunName, Status = testRunCommand.Status }; var currentWorkflow = WorkflowCollection.Workflows.FirstOrDefault(wfl => testRunCommand.WorkflowName == wfl.Name); SetCommonData(testRun, currentWorkflow.DefaultData.Data); SetWorkflow(testRunCommand, testRun); SetStartUpParameters(testRun); SetCommonData(testRun, formData); SetCreatedTime(testRun); return testRun; }
bool PrepareTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { var testRunInitializer = ServerObjectFactory.Resolve<TestRunInitializer>(); var testRun = testRunInitializer.CreateTestRun(testRunCommand, formData); CurrentTestRunId = testRun.Id; if (Guid.Empty == testRun.WorkflowId) // ?? return false; TestRunQueue.TestRuns.Add(testRun); foreach (var testRunAction in testRun.BeforeActions) { testRunAction.Run(); } return true; }
TestRunCommand WhenSendingTestRunAsJson(string testWorkflowName, TestRunStatuses status, string alternativeUrl, ITestRunCommand testRunCommand) { var testRun = new TestRun(); (testRun as TestRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName)); if (null == testRunCommand) _response = _browser.Get(alternativeUrl, with => { // with.JsonBody(testRunCommand); with.Accept("application/json"); }); else _response = _browser.Get(alternativeUrl, with => { with.JsonBody(testRunCommand); with.Accept("application/json"); }); Xunit.Assert.Equal(HttpStatusCode.Created, _response.StatusCode); return _response.Body.DeserializeJson<TestRunCommand>(); }
public virtual ITestRun CreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { if (string.IsNullOrEmpty(testRunCommand.TestRunName)) { testRunCommand.TestRunName = testRunCommand.WorkflowName + " " + DateTime.Now; } var testRun = new TestRun { Name = testRunCommand.TestRunName, Status = testRunCommand.Status }; var currentWorkflow = WorkflowCollection.Workflows.FirstOrDefault(wfl => testRunCommand.WorkflowName == wfl.Name); SetCommonData(testRun, currentWorkflow.DefaultData.Data); SetWorkflow(testRunCommand, testRun); SetStartUpParameters(testRun); SetCommonData(testRun, formData); SetCreatedTime(testRun); return(testRun); }
public virtual bool SetTestRunDataAndCreateTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { CurrentTestRunId = Guid.Empty; if (null == testRunCommand) { testRunCommand = new TestRunCommand { TestRunName = formData[Resources.TestRunCommand_testRunName_param] ?? string.Empty, WorkflowName = formData[Resources.TestRunCommand_workflowName_param] ?? string.Empty } } ; if (string.IsNullOrEmpty(testRunCommand.WorkflowName)) { testRunCommand.WorkflowName = formData[Resources.TestRunCommand_workflowName_param] ?? string.Empty; } if (string.IsNullOrEmpty(testRunCommand.TestRunName)) { testRunCommand.TestRunName = formData[Resources.TestRunCommand_testRunName_param] ?? string.Empty; } return(PrepareTestRun(testRunCommand, formData)); } bool PrepareTestRun(ITestRunCommand testRunCommand, DynamicDictionary formData) { var testRunInitializer = ServerObjectFactory.Resolve <TestRunInitializer>(); var testRun = testRunInitializer.CreateTestRun(testRunCommand, formData); CurrentTestRunId = testRun.Id; if (Guid.Empty == testRun.WorkflowId) // ?? { return(false); } TestRunQueue.TestRuns.Add(testRun); foreach (var testRunAction in testRun.BeforeActions) { testRunAction.Run(); } return(true); }
TestRunCommand WHEN_sending_testRun_as_json(string testWorkflowName, TestRunStatuses status, string alternativeUrl, ITestRunCommand testRunCommand) { var testRun = new TestRun(); // var testRunCommand = new TestRunCommand { WorkflowName = testWorkflowName, Status = status }; (testRun as TestRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName)); if (null == testRunCommand) _response = _browser.Post(alternativeUrl, with => { // with.JsonBody(testRunCommand); with.Accept("application/json"); }); else _response = _browser.Post(alternativeUrl, with => { with.JsonBody(testRunCommand); with.Accept("application/json"); }); return _response.Body.DeserializeJson<TestRunCommand>(); }
void SetWorkflow(ITestRunCommand testRunCommand, TestRun testRun) { testRun.SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testRunCommand.WorkflowName)); TestLabCollection.TestLabs.First(testLab => testLab.Id == testRun.TestLabId).Status = TestLabStatuses.Busy; }
void WhenSendingTestRunAsJson(string testWorkflowName, string alternativeUrl, ITestRunCommand testRunCommand) { var testRun = new TestRun(); ((TestRun) testRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName)); if (null == testRunCommand) _response = _browser.Post(alternativeUrl, with => { // with.JsonBody(testRunCommand); with.Accept("application/json"); }); else _response = _browser.Post(alternativeUrl, with => { with.JsonBody(testRunCommand); with.Accept("application/json"); }); }
void WhenSendingTestRunAsJson(string testWorkflowName, string alternativeUrl, ITestRunCommand testRunCommand) { var testRun = new TestRun(); ((TestRun)testRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName)); if (null == testRunCommand) { _response = _browser.Post(alternativeUrl, with => { // with.JsonBody(testRunCommand); with.Accept("application/json"); }); } else { _response = _browser.Post(alternativeUrl, with => { with.JsonBody(testRunCommand); with.Accept("application/json"); }); } }
TestRunCommand WhenSendingTestRunAsJson(string testWorkflowName, TestRunStatuses status, string alternativeUrl, ITestRunCommand testRunCommand) { var testRun = new TestRun(); (testRun as TestRun).SetWorkflow(WorkflowCollection.Workflows.First(wfl => wfl.Name == testWorkflowName)); if (null == testRunCommand) { _response = _browser.Get(alternativeUrl, with => { // with.JsonBody(testRunCommand); with.Accept("application/json"); }); } else { _response = _browser.Get(alternativeUrl, with => { with.JsonBody(testRunCommand); with.Accept("application/json"); }); } Xunit.Assert.Equal(HttpStatusCode.Created, _response.StatusCode); return(_response.Body.DeserializeJson <TestRunCommand>()); }