public async Task <DebugTestGetStartInfoResponse> Handle(DebugTestClassGetStartInfoRequest request)
        {
            var testManager = CreateTestManager(request.FileName, request.NoBuild);

            _debugSessionManager.StartSession(testManager);

            return(await _debugSessionManager.DebugGetStartInfoAsync(request.MethodNames, request.RunSettings, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None));
        }
示例#2
0
        public Task <DebugTestGetStartInfoResponse> Handle(DebugTestGetStartInfoRequest request)
        {
            var testManager = CreateTestManager(request.FileName);

            _debugSessionManager.StartSession(testManager);

            return(_debugSessionManager.DebugGetStartInfoAsync(request.MethodName, request.TestFrameworkName, CancellationToken.None));
        }
示例#3
0
        public Task <DebugTestGetStartInfoResponse> Handle(DebugTestGetStartInfoRequest request)
        {
            var testManager = CreateTestManager(request.FileName);

            if (testManager.IsConnected)
            {
                //only if the test manager connected successfully, shall we proceed with the request
                _debugSessionManager.StartSession(testManager);
                return(_debugSessionManager.DebugGetStartInfoAsync(request.MethodName, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None));
            }

            throw new InvalidOperationException("The debugger could not be started");
        }
        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
            });
        }