Example #1
0
        public string PerformResultInsertion(string input, IntellisenseProviderContext context)
        {
            VerifyArgument.IsNotNull("context", context);
            if (input == String.Empty)
            {
                return(context.InputText);
            }
            var resbuilder    = new IntellisenseStringResultBuilder();
            var editorText    = context.InputText;
            var originalText  = context.InputText;
            var originalCaret = context.CaretPosition;

            if (originalText == String.Empty || input.StartsWith(originalText))
            {
                var result = resbuilder.Build(input, originalCaret, originalText, editorText);
                context.CaretPosition = result.CaretPosition;
                return(result.Result);
            }
            // ReSharper disable once RedundantIfElseBlock
            else
            {
                var result = resbuilder.Build(input, originalCaret, originalText, editorText);
                context.CaretPosition = result.CaretPosition;
                return(result.Result);
            }
        }
Example #2
0
        public void WhenISelectTheFollowingStringOption(string option)
        {
            var originalText = ScenarioContext.Current["inputText"].ToString();
            var caretpos     = int.Parse(ScenarioContext.Current["cursorIndex"].ToString());

            if (option == "")
            {
                ScenarioContext.Current["stringResult"] = new IntellisenseStringResult(originalText, caretpos);
                return;
            }

            var options = ScenarioContext.Current["stringOptions"] as IEnumerable <string>;

            Assert.IsTrue(options.Contains(option));

            var builder = new IntellisenseStringResultBuilder();
            var res     = builder.Build(option, caretpos, originalText, originalText);

            ScenarioContext.Current["stringResult"] = res;
        }