Exemple #1
0
        public async Task <RunTestResponse> Handle(RunTestsInContextRequest request)
        {
            var document = Workspace.GetDocument(request.FileName);

            if (document is null)
            {
                return(new RunTestResponse
                {
                    Failure = "File is not part of a C# project in the loaded solution.",
                    Pass = false,
                    ContextHadNoTests = true
                });
            }

            using var testManager = TestManager.Create(document.Project, DotNetCli, EventEmitter, LoggerFactory);

            var(methodNames, testFramework) = await testManager.GetContextTestMethodNames(request.Line, request.Column, document, CancellationToken.None);

            if (methodNames is null)
            {
                return(new RunTestResponse
                {
                    Pass = false,
                    Failure = "Could not find any tests to run",
                    ContextHadNoTests = true
                });
            }

            testManager.Connect(request.NoBuild);

            if (testManager.IsConnected)
            {
                return(await testManager.RunTestAsync(methodNames, request.RunSettings, testFramework, request.TargetFrameworkVersion, CancellationToken.None));
            }

            var response = new RunTestResponse
            {
                Failure           = "Failed to connect to 'dotnet test' process",
                Pass              = false,
                ContextHadNoTests = false
            };

            return(response);
        }
        public async Task <DebugTestGetStartInfoResponse> Handle(DebugTestsInContextGetStartInfoRequest request)
        {
            var document = Workspace.GetDocument(request.FileName);

            if (document is null)
            {
                return(new DebugTestGetStartInfoResponse
                {
                    Succeeded = false,
                    FailureReason = "File is not part of a C# project in the loaded solution.",
                    ContextHadNoTests = true,
                });
            }

            var testManager = TestManager.Create(document.Project, DotNetCli, EventEmitter, LoggerFactory);

            var(methodNames, testFramework) = await testManager.GetContextTestMethodNames(request.Line, request.Column, document, CancellationToken.None);

            if (methodNames is null)
            {
                return(new DebugTestGetStartInfoResponse
                {
                    Succeeded = false,
                    FailureReason = "Could not find any tests to run",
                    ContextHadNoTests = true,
                });
            }

            testManager.Connect(request.NoBuild);

            if (testManager.IsConnected)
            {
                _debugSessionManager.StartSession(testManager);
                return(await _debugSessionManager.DebugGetStartInfoAsync(methodNames, request.RunSettings, testFramework, request.TargetFrameworkVersion, CancellationToken.None));
            }

            return(new DebugTestGetStartInfoResponse
            {
                FailureReason = "Failed to connect to the 'dotnet test' process",
                Succeeded = false
            });
        }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                GrabUserInput();
                var manager = new TestManager();
                if (Mode == FormMode.CreateNew)
                {
                    manager.Create(Test);
                }
                else
                {
                    manager.Update(Test);
                }

                MyForms.GetForm <TestlistForm>().LoadData();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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();
            }
        }