public void When_A_Background_Is_Present_Its_Included_In_Markdown_Output() { var mockStyle = new MockStylist { FeatureHeadingFormat = "FeatureHeading: {0}", BackgroundHeadingFormat = "BackgroundHeading: {0}" }; var feature = new Feature { Name = "Feature with Background" }; feature.AddBackground(new Scenario()); var featureBlock = new FeatureBlock(feature, mockStyle); var results = new string[featureBlock.Lines.Count]; var i = 0; foreach (var line in featureBlock.Lines) { results[i] = line; i++; } Assert.AreEqual("FeatureHeading: Feature with Background", results[0]); Assert.AreEqual("BackgroundHeading:", results[2]); Assert.AreEqual(3, results.Length); }
public void Then_feature_with_background_is_added_successfully() { var excelFeatureFormatter = Container.Resolve <ExcelFeatureFormatter>(); var feature = new Feature { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", Tags = { "tag1", "tag2" } }; var background = new Scenario { Name = "Test Background Scenario", Description = "In order to test this background,\nAs a developer\nI want to test this background", Tags = { "tag1", "tag2" } }; var given = new Step { NativeKeyword = "Given", Name = "a precondition" }; background.Steps = new List <Step>(new[] { given }); feature.AddBackground(background); using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); Check.That(worksheet.Cell("B5").Value).IsEqualTo(background.Name); Check.That(worksheet.Cell("C6").Value).IsEqualTo("tag1, tag2"); Check.That(worksheet.Cell("C7").Value).IsEqualTo(background.Description); Check.That(worksheet.Cell("D8").Value).IsEqualTo(given.Name); } }
public void Should_convert_background_to_string() { var feature = new Feature("Title", string.Format(" As a x{0} I want y{0} So that z", Environment.NewLine), "source", 1); var background = new Scenario("backgroundTitle", "source", feature, 4); background.AddStep(new StringStep("Given a background step", "source, 5")); feature.AddBackground(background); var featureAsString = feature.ToString(); string expected = string.Format("Feature: Title{0} As a x{0} I want y{0} So that z", Environment.NewLine); expected += string.Format("{0}{0} Background: backgroundTitle{0} Given a background step", Environment.NewLine); Assert.AreEqual(expected, featureAsString); }
public void Should_convert_background_to_string() { var feature = new Feature("Title", string.Format(" As a x{0} I want y{0} So that z", Environment.NewLine), "source", 1); var background = new Scenario("backgroundTitle", "source", feature, 4); background.AddStep(new StringStep("Given", "a background step", "source, 5")); feature.AddBackground(background); var featureAsString = feature.ToString(); string expected = string.Format("Feature: Title{0} As a x{0} I want y{0} So that z", Environment.NewLine); expected += string.Format("{0}{0} Background: backgroundTitle{0} Given a background step", Environment.NewLine); Assert.AreEqual(expected, featureAsString); }
public void ThenCanReadBackgroundResultSuccessfully() { var background = new Scenario { Name = "Background", Feature = _feature }; _feature.AddBackground(background); TestResult result = _results.GetScenarioResult(background); result.WasExecuted.ShouldBeFalse(); result.WasSuccessful.ShouldBeFalse(); }
public FeatureBuilder(IGherkinParserEvents gherkinParser) { gherkinParser.FeatureEvent += (s, e) => { feature = e.EventInfo; }; gherkinParser.ScenarioEvent += (s, e) => { CreateFeatureIfNull(e.EventInfo.Source); feature.AddScenario(e.EventInfo); }; gherkinParser.BackgroundEvent += (s, e) => { CreateFeatureIfNull(e.EventInfo.Source); feature.AddBackground(e.EventInfo); }; gherkinParser.EofEvent += (s, e) => { feature = null; }; }
public void Map_WithBackground_ReturnsBackground() { var feature = new Feature(); feature.AddBackground( new Scenario { Description = "The description of the background" }); var mapper = CreateMapper(); var actual = mapper.Map(feature); Check.That(actual.Background.Description).IsEqualTo("The description of the background"); Check.That(actual.Background.Feature).IsSameReferenceThan(actual); }