public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 {
     if (pguidCmdGroup == GuidList.guidLocalRefactorCmdSet)
     {
         if (nCmdID == PkgCmdIDList.cmdidExtractVariable)
         {
             codeManipulator.ExtractVariable();
             return(VSConstants.S_OK);
         }
         if (nCmdID == PkgCmdIDList.cmdidExtractConstant)
         {
             codeManipulator.ExtractConstant();
             return(VSConstants.S_OK);
         }
         if (nCmdID == PkgCmdIDList.cmdidAssignParameter)
         {
             codeManipulator.AssignParameterToField();
             return(VSConstants.S_OK);
         }
         if (nCmdID == PkgCmdIDList.cmdidConvertVariable)
         {
             codeManipulator.ConvertVariableToField();
             return(VSConstants.S_OK);
         }
     }
     return(Next.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
 }
        public void ShouldExtractVariableAndInsertVariableOnLineBeforeThatContainingTheExpression()
        {
            StringTextBuffer testBuffer = new StringTextBuffer(ExpressionInContext("int x = a - b + c * d / e % 3444;"));

            mockView.Setup(m => m.TextBuffer).Returns(testBuffer);
            mockView.Setup(m => m.Selection).Returns(testBuffer.Select("a - b + c"));
            mockNameProvider.Setup(m => m.GetName()).Returns("expression");

            manipulator.ExtractVariable();

            Console.Out.Write(testBuffer.CurrentSnapshot.GetText());


            Assert.AreEqual("            var expression = a - b + c;", testBuffer.CurrentSnapshot.Lines.ElementAt(8).GetText());
            Assert.AreEqual("            int x = expression * d / e % 3444;", testBuffer.CurrentSnapshot.Lines.ElementAt(9).GetText());
        }