public static TestCaseProxy TestCaseModelToProxy(TestCase model) { TestCaseProxy proxyObject = new TestCaseProxy(); proxyObject.Id = model.ID; proxyObject.Title = model.Title; proxyObject.Priority = EnumUtil.ParseEnum<Priority>(model.Priority); proxyObject.Severity = EnumUtil.ParseEnum<Severity>(model.Severity); proxyObject.IsAutomated = model.IsAutomated; proxyObject.CreatedBy = model.CreatedBy; proxyObject.UpdatedBy = model.UpdatedBy; proxyObject.AreaID = model.AreaID; foreach (var item in new TestManager().GetStepDefinitionsById(model.ID)) { StepDefinitionProxy proxy = new StepDefinitionProxy(); proxy.Step = item.Step; proxy.ExpectedResult = item.ExpectedResult; proxy.ID = item.ID; proxy.TestCaseID = item.TestCaseID; proxyObject.StepDefinitionList.Add(proxy); } return proxyObject; }
public static TestRunProxy TestRunModelToProxy(TestRun run) { TestRunProxy runProxy = new TestRunProxy(); runProxy.ID = run.ID; runProxy.Name = run.Name; runProxy.CreatedBy = run.CreatedBy; runProxy.CreatedOn = run.CreatedOn; IEnumerable<TestComposite> compositeModel = new TestRunManager().GetCompositeByRunId(runProxy.ID); foreach (TestComposite comp in compositeModel) { ExtendedTestCaseProxy extendedTestCaseProxy = new ExtendedTestCaseProxy(); extendedTestCaseProxy.Status = EnumUtil.ParseEnum<Status>(comp.TestCaseStatus); TestCase testCase = new TestManager().GetById(comp.TestCaseID); extendedTestCaseProxy.Id = testCase.ID; extendedTestCaseProxy.Title = testCase.Title; extendedTestCaseProxy.Priority = EnumUtil.ParseEnum<Priority>(testCase.Priority); extendedTestCaseProxy.Severity = EnumUtil.ParseEnum<Severity>(testCase.Severity); extendedTestCaseProxy.IsAutomated = testCase.IsAutomated; extendedTestCaseProxy.CreatedBy = testCase.CreatedBy; extendedTestCaseProxy.UpdatedBy = testCase.UpdatedBy; extendedTestCaseProxy.AreaID = testCase.AreaID; foreach (var item in new TestManager().GetStepDefinitionsById(testCase.ID)) { StepDefinitionProxy proxy = new StepDefinitionProxy(); proxy.Step = item.Step; proxy.ExpectedResult = item.ExpectedResult; proxy.ID = item.ID; proxy.TestCaseID = item.TestCaseID; extendedTestCaseProxy.StepDefinitionList.Add(proxy); } runProxy.TestCasesList.Add(extendedTestCaseProxy); } return runProxy; }
private void CreateTestCase(object sender, RoutedEventArgs e) { this.TestCaseTitleValidation(this.TestCaseTitle.Text); if (!string.IsNullOrWhiteSpace(this.TestCaseTitle.Text)) { TestCaseProxy testCase = new TestCaseProxy(); testCase.Id = this.testCaseId; testCase.Title = this.TestCaseTitle.Text; testCase.Priority = EnumUtil.ParseEnum<Priority>((this.PriorityComboBox.SelectedItem as ComboBoxItem).Content.ToString()); testCase.Severity = EnumUtil.ParseEnum<Severity>((this.SeverityComboBox.SelectedItem as ComboBoxItem).Content.ToString()); testCase.IsAutomated = this.IsAutomatedCheckBox.IsChecked ?? false; testCase.StepDefinitionList = new ObservableCollection<StepDefinitionProxy>(); foreach (var item in this.TestStepList.ItemsSource) { StepDefinitionProxy stepDefinition = new StepDefinitionProxy(); stepDefinition.ID = (item as StepDefinitionProxy).ID; stepDefinition.Step = (item as StepDefinitionProxy).Step; stepDefinition.ExpectedResult = (item as StepDefinitionProxy).ExpectedResult; stepDefinition.TestCaseID = testCase.Id; testCase.StepDefinitionList.Add(stepDefinition); } TestManager manager = new TestManager(); if (!this.isEditingExistingTestCase) { TestCaseDialog.testCase = ProxyConverter.TestCaseModelToProxy(manager.Create(relatedArea.ID, ModelConverter.TestCaseProxyToModel(testCase))); } else { TestCaseDialog.testCase = ProxyConverter.TestCaseModelToProxy(manager.Update(ModelConverter.TestCaseProxyToModel(testCase))); } this.CancelDialog(); } }