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); }
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); }
private StubWpfTextView CreateTextView(TestText inputText, string newLine = null) { return(StubWpfTextView.CreateTextView(_ideScope, inputText, newLine)); }