Exemplo n.º 1
0
        private static GaugeServiceClient GetGaugeServiceClient(string input, string parsedInput,
                                                                IGaugeService gaugeService,
                                                                EnvDTE.Project project)
        {
            var gaugeServiceClient = new GaugeServiceClient(gaugeService);
            var gaugeApiConnection = A.Fake <IGaugeApiConnection>();
            var response           = new APIMessage
            {
                MessageType       = APIMessage.Types.APIMessageType.GetStepValueResponse,
                MessageId         = 0,
                StepValueResponse = new GetStepValueResponse
                {
                    StepValue = new ProtoStepValue
                    {
                        ParameterizedStepValue = input,
                        StepValue = parsedInput
                    }
                }
            };

            A.CallTo(() => gaugeApiConnection.WriteAndReadApiMessage(A <APIMessage> ._))
            .Returns(response);
            A.CallTo(() => gaugeService.GetApiConnectionFor(project)).Returns(gaugeApiConnection);
            return(gaugeServiceClient);
        }
Exemplo n.º 2
0
        public void ShouldGetParsedValueFromGauge()
        {
            const string expected = "foo message with {}";
            const string input    = "foo message with <parameter>";

            var gaugeService       = A.Fake <IGaugeService>();
            var project            = A.Fake <EnvDTE.Project>();
            var gaugeApiConnection = A.Fake <IGaugeApiConnection>();

            var response = new APIMessage
            {
                MessageType       = APIMessage.Types.APIMessageType.GetStepValueResponse,
                MessageId         = 0,
                StepValueResponse = new GetStepValueResponse
                {
                    StepValue = new ProtoStepValue
                    {
                        ParameterizedStepValue = input,
                        StepValue = expected
                    }
                }
            };

            A.CallTo(() => gaugeApiConnection.WriteAndReadApiMessage(A <APIMessage> ._))
            .Returns(response);
            A.CallTo(() => gaugeService.GetApiConnectionFor(project)).Returns(gaugeApiConnection);
            var gaugeServiceClient = new GaugeServiceClient(gaugeService);

            var actual = gaugeServiceClient.GetParsedStepValueFromInput(project, input);

            Assert.AreEqual(expected, actual);
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(Next.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            var hresult = VSConstants.S_OK;

            switch ((VSConstants.VSStd97CmdID)nCmdID)
            {
            case VSConstants.VSStd97CmdID.FindReferences:
                var caretBufferPosition = TextView.Caret.Position.BufferPosition;
                var originalText        = Step.GetStepText(caretBufferPosition.GetContainingLine());

                var findRegex =
                    new GaugeServiceClient().GetFindRegex(caretBufferPosition.Snapshot.GetProject(GaugePackage.DTE),
                                                          originalText);

                var _dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
                var find = (Find2)_dte.Find;

                var types     = find.FilesOfType;
                var matchCase = find.MatchCase;
                var matchWord = find.MatchWholeWord;

                find.WaitForFindToComplete = false;
                find.Action            = vsFindAction.vsFindActionFindAll;
                find.Backwards         = false;
                find.MatchInHiddenText = true;
                find.MatchWholeWord    = true;
                find.MatchCase         = false;
                find.PatternSyntax     = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr;
                find.ResultsLocation   = vsFindResultsLocation.vsFindResults1;
                find.SearchSubfolders  = true;
                find.Target            = vsFindTarget.vsFindTargetSolution;
                find.FindWhat          = findRegex;
                find.Execute();

                find.FilesOfType    = types;
                find.MatchCase      = matchCase;
                find.MatchWholeWord = matchWord;

                return(hresult);

            default:
                hresult = Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                break;
            }
            return(hresult);
        }
Exemplo n.º 4
0
        public void ShouldThrowExceptionWhenGetParsedValueWithApiNotInitialized()
        {
            const string input = "foo message with <parameter>";

            var gaugeService = A.Fake <IGaugeService>();
            var project      = A.Fake <EnvDTE.Project>();

            A.CallTo(() => gaugeService.GetApiConnectionFor(project)).Throws(() => new GaugeApiInitializationException());
            var gaugeServiceClient = new GaugeServiceClient(gaugeService);


            Assert.Throws <GaugeApiInitializationException>(() =>
                                                            gaugeServiceClient.GetParsedStepValueFromInput(project, input));
        }