public void DefaultUseCase(IClipboard clipboard, GherkinPaster sut, TestEnvironment environment) { "Given a complete system".Given(() => { environment = FakesLibrary.CreateDefaultEnvironment(); sut = new GherkinPaster(environment); }); "And a gherkin Scenario".And(() => { var sb = new StringBuilder(); sb.AppendLine("Scenario: Testing the gherkin paster"); sb.AppendLine("Given a line"); sb.AppendLine("And a line"); sb.AppendLine("When a line"); sb.AppendLine("Then a line"); clipboard = FakesLibrary.CreateShim(sb.ToString()); }); "When the gherkin is pasted".When(() => sut.PasteGherkin(clipboard)); "Then the output should be a method wrapping 4 strings with appropriate extension methods".Then(() => { var expectedOutput = @"[Scenario] public void TestingTheGherkinPaster() { ""Given a line"".Given(() => {}); ""And a line"".And(() => {}); ""When a line"".When(() => {}); ""Then a line"".Then(() => {}); } "; environment.TextWritten.Should() .Be(expectedOutput); }); }
public void PastingDoubleQuotesInScenario(IClipboard clipboard, GherkinPaster sut, TestEnvironment environment) { "Given a complete system".Given(() => { environment = FakesLibrary.CreateDefaultEnvironment(); sut = new GherkinPaster(environment); }); "and a scenario containing a 'double quote'".And(() => clipboard = FakesLibrary.CreateShim("Scenario: With a \" character")); "When the single line is pasted".Then(() => sut.PasteGherkin(clipboard)); "Then the 'double quote' character has been removed".Then(() => environment.LinesWritten.Any(l => l.Contains("\"")) .Should() .BeFalse()); }
public void SingleLinePaste(IClipboard clipboard, GherkinPaster sut, TestEnvironment environment) { "Given a complete system".Given(() => { environment = FakesLibrary.CreateDefaultEnvironment(); sut = new GherkinPaster(environment); }); "and a single line of valid gherkin".And(() => clipboard = FakesLibrary.CreateShim("Given a single line")); "When the single line is pasted".Then(() => sut.PasteGherkin(clipboard)); "Then only a single line is received by the environment".Then(() => environment.LinesWritten.Count() .Should() .Be(1)); }
public void PAstingDoubleQuotesInGWTIClipboard(IClipboard clipboard, GherkinPaster sut, TestEnvironment environment) { "Given a complete system".Given(() => { environment = FakesLibrary.CreateDefaultEnvironment(); sut = new GherkinPaster(environment); }); "and a line containing a 'double quote'".And(() => clipboard = FakesLibrary.CreateShim("Given a \" character")); "When the line is pasted".Then(() => sut.PasteGherkin(clipboard)); "then the 'double quote' character has been replaced by the 'backlash' and 'boudle quote' characters".Then(() => { environment.LinesWritten[0].Should() .Be("\"Given a \\\" character\".Given(() => {});"); }); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { var dte = (DTE2) GetService(typeof (DTE)); var gherkinPaster = new GherkinPaster(new EnvironmentShim(dte)); gherkinPaster.PasteGherkin(ClipboardShim.Instance); }