Exemple #1
0
        public void TagsAreReportedInTextReport()
        {
            var story = this.Given(_ => GivenAStep())
                .WithTags("Tag1", "Tag 2")
                .BDDfy();

            var textReporter = new TextReporter();
            textReporter.Process(story);

            textReporter.ToString().ShouldMatchApproved();
        }
        public void FluentCanBeUsedWithExamplesEndingInANumber() {
            var story = this
                .Given(_ => MethodTaking__ExampleInt1__(1), false)
                .When(_ => WhenEmptyMethod())
                .Then(_ => ThenAllIsGood())
                .BDDfy();

            var textReporter = new TextReporter();
            textReporter.Process(story);
            textReporter.ToString().ShouldMatchApproved();
        }
        public void Inline()
        {
            // ReSharper disable once ConvertToConstant.Local
            var inlineVariable = 0;
            var story = this
                .Given(_ => GivenIntWithValue(inlineVariable))
                .WithExamples(new ExampleTable("Inline Variable") { 1, 2 })
                .BDDfy();

            var textReporter = new TextReporter();
            textReporter.Process(story);
            textReporter.ToString().ShouldMatchApproved();
        }
        public void Run()
        {
            var story = this
                .WithExamples(new ExampleTable("First Example", "Second Example")
                {
                    {1, "foo"},
                    {2, "bar"}
                })
                .BDDfy();

            var reporter = new TextReporter();
            reporter.Process(story);
            Approvals.Verify(reporter.ToString());
        }
        public void ShouldProduceExpectedTextWithExamples()
        {
            var stories = new ReportTestData().CreateTwoStoriesEachWithOneFailingScenarioAndOnePassingScenarioWithThreeStepsOfFiveMillisecondsAndEachHasTwoExamples();
            var actual = new StringBuilder();

            foreach (var story in stories)
            {
                var textReporter = new TextReporter();
                textReporter.Process(story);
                actual.AppendLine(textReporter.ToString());
            }

            Approvals.Verify(actual.ToString(), StackTraceScrubber.ScrubStackTrace);
        }
        public void ShouldProduceExpectedReport()
        {
            var stories = new ReportTestData().CreateMixContainingEachTypeOfOutcomeWithOneScenarioPerStory();
            var actual = new StringBuilder();

            foreach (var story in stories)
            {
                var textReporter = new TextReporter();
                textReporter.Process(story);
                actual.AppendLine(textReporter.ToString());
            }

            Approvals.Verify(actual.ToString(), StackTraceScrubber.ScrubStackTrace);
        }
        public void ShouldProduceExpectedReport()
        {
            var stories = new ReportTestData().CreateMixContainingEachTypeOfOutcomeWithOneScenarioPerStory();
            var actual = new StringBuilder();

            foreach (var story in stories)
            {
                var textReporter = new TextReporter();
                textReporter.Process(story);
                actual.AppendLine(textReporter.ToString());
            }

            actual.ToString().ShouldMatchApproved(c => c.WithScrubber(ReportApprover.Scrub));
        }
 public void LongStepName()
 {
     var textReporter = new TextReporter();
     var scenario = new Scenario(typeof(TextReporterTests), new List<Step>
     {
         new Step(o => null, new StepTitle("Given a normal length title"), false, ExecutionOrder.SetupState, true, new List<StepArgument>()),
         new Step(o => null, new StepTitle("When something of normal length happens"), false, ExecutionOrder.Transition, true, new List<StepArgument>()),
         new Step(o => null, new StepTitle("Then some long state should be: #Title\r\n\r\nSome more stuff which is quite long on the second line\r\n\r\nAnd finally another really long line"),
             true, ExecutionOrder.Assertion, true, new List<StepArgument>()),
         new Step(o => null, new StepTitle("And a normal length assertion"), true, ExecutionOrder.ConsecutiveAssertion, true, new List<StepArgument>())
     }, "Scenario Text", new List<string>());
     textReporter.Process(new Story(new StoryMetadata(typeof(TextReporterTests), new StoryNarrativeAttribute()),
         scenario));
     var actual = new StringBuilder();
     actual.AppendLine(textReporter.ToString());
     Approvals.Verify(actual.ToString(), StackTraceScrubber.ScrubStackTrace);
 }
        public void VerifyPrependStepTitles()
        {
            var story = this.Given(_ => GivenAStepWithGivenInIt())
                .Given(_ => AStepWithoutGivenInIt())
                .And(_ => AndGivenAStepWithAndGivenInIt())
                .And(_ => AStepWithoutGivenInIt())
                .But(_ => ButInStep())
                .But(_ => NothingInStep())
                .When(_ => WhenStuff())
                .When(_ => Stuff())
                .Then(_ => ThenWeAreWinning())
                .Then(_ => WeAreWinning())
                .BDDfy();

            var textReporter = new TextReporter();
            textReporter.Process(story);
            Approvals.Verify(textReporter.ToString());
        }
        public void CanUseActionsInExamples()
        {
            ExampleAction actionToPerform = null;
            int valueShouldBe = 0;
            var story = this.Given(_ => SomeSetup())
                .When(() => actionToPerform)
                .Then(_ => ShouldBe(valueShouldBe))
                .WithExamples(new ExampleTable("Action to perform", "Value should be")
                {
                    { new ExampleAction("Do something", () => { _value = 42; }), 42 },
                    { new ExampleAction("Do something else", () => { _value = 7; }), 7 }
                })
                .BDDfy();


            var textReporter = new TextReporter();
            textReporter.Process(story);
            textReporter.ToString().ShouldMatchApproved();
        }
        public void FluentCanBeUsedWithExamples()
        {
            var story = this
                .Given(_ => MethodTaking__ExampleInt__(Prop1), false)
                .And(_ => MethodTaking__ExampleInt__(_.Prop1), false)
                .And(_ => ADifferentMethodWithRandomArg(2))
                .And(_ => ADifferentMethodWith(_prop2))
                .When(_ => WhenMethodUsing__ExampleString__())
                .And(_ => AndIUseA(multiWordHeading))
                .Then(_ => ThenAllIsGood())
                .WithExamples(new ExampleTable("Prop 1", "Prop2", "Prop 3", "Multi word heading")
                {
                    {1, "foo", ExecutionOrder.ConsecutiveAssertion, "" },
                    {2, "bar", ExecutionOrder.Initialize, "val2" }
                })
                .BDDfy();

            var textReporter = new TextReporter();
            textReporter.Process(story);
            textReporter.ToString().ShouldMatchApproved();
        }