示例#1
0
        public void GivenTheFollowingCStepDefinitionClassInTheEditor(string stepDefinitionClass)
        {
            var fileName           = "Steps.cs";
            var stepDefinitionFile =
                string.Join(Environment.NewLine, new[]
            {
                "using System;",
                "using TechTalk.SpecFlow;",
                "",
                "namespace MyProject",
                "{",
                stepDefinitionClass,
                "}"
            });
            var namespaceValue   = Regex.Match(stepDefinitionFile, @"namespace (?<value>\S+)").Groups["value"].Value;
            var classValue       = Regex.Match(stepDefinitionFile, @"public class (?<value>\S+)").Groups["value"].Value;
            var methodValue      = Regex.Match(stepDefinitionFile, @"public void (?<value>[^\(\s]+)").Groups["value"].Value;
            var stepDefTypeValue = Regex.Match(stepDefinitionFile, @"\[(?<value>Given|When|Then)\(").Groups["value"].Value;
            var regexValue       = Regex.Match(stepDefinitionFile, @"\[(?:Given|When|Then)\(\@?""(?<value>.*?)""\)\]").Groups["value"].Value;
            var locationMatch    = Regex.Match(stepDefinitionFile, @"^(?<line>.*\r\n)*\s*\[(?:Given|When|Then)");

            var stepDefinition = new StepDefinition()
            {
                Regex          = regexValue,
                Method         = $"{namespaceValue}.{classValue}.{methodValue}",
                ParamTypes     = "",
                Type           = stepDefTypeValue,
                SourceLocation = $"{fileName}|{locationMatch.Groups["line"].Captures.Count + 3}|1"
            };

            _ideScope.Logger.LogInfo(stepDefinition.SourceLocation);
            RegisterStepDefinitions(stepDefinition);
            WhenTheProjectIsBuilt();
            _wpfTextView = StubWpfTextView.CreateTextView(_ideScope, new TestText(stepDefinitionFile), projectScope: _projectScope, contentType: "text", filePath: fileName);
        }
示例#2
0
        public void GivenTheFollowingFeatureFileInTheEditor(string featureFileContent)
        {
            var fileName = "Feature1.feature";
            var filePath = Path.Combine(_projectScope.ProjectFolder, fileName);

            _projectScope.FilesAdded.Add(filePath, featureFileContent);

            _wpfTextView = StubWpfTextView.CreateTextView(_ideScope, new TestText(featureFileContent), projectScope: _projectScope);
        }
示例#3
0
        protected IWpfTextView CreateTextView(TestText inputText, int selectionStartLine, int selectionStartColumn,
                                              int?selectionEndLine, int?selectionEndColumn)
        {
            var          textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString());
            IWpfTextView textView   = new StubWpfTextView(textBuffer);

            if (selectionEndColumn != null && selectionEndLine != null)
            {
                textView.Selection.Select(new SnapshotSpan(
                                              inputText.GetSnapshotPoint(textView.TextSnapshot, selectionStartLine, selectionStartColumn),
                                              inputText.GetSnapshotPoint(textView.TextSnapshot, selectionEndLine.Value, selectionEndColumn.Value)),
                                          false);
            }

            int caretLine   = selectionEndLine ?? selectionStartLine;
            int caretColumn = selectionEndColumn ?? selectionStartColumn;

            textView.Caret.MoveTo(inputText.GetSnapshotPoint(textView.TextSnapshot, caretLine, caretColumn));
            return(textView);
        }
示例#4
0
 private StubWpfTextView CreateTextView(TestText inputText, string newLine = null)
 {
     return(StubWpfTextView.CreateTextView(_ideScope, inputText, newLine));
 }