Example #1
0
    void Ex01()
    {
        FormattedDescription = Formatter.FormatFixtureStep(FixtureSteps.CreateGivenStep(Description));

        Expect("the first line indent of the formatted description should be empty", () => FormattedDescription.FirstLineIndent == string.Empty);
        Expect("the line count of the formatted description should be 1", () => FormattedDescription.Lines.Count() == 1);
        Expect("the first element of the formatted description line should be 'Given {the description of GivenStep}'", () => FormattedDescription.Lines.ElementAt(0) == $"Given {Description}");
        Expect("the line indent of the formatted description should be '      '(6 spaces)", () => FormattedDescription.LineIndent == "      ");
        Expect("the items of the formatted description should be empty", () => !FormattedDescription.Items.Any());
    }
 void Ex03()
 {
     Given("GivenStep that does not have an arrangement", () =>
     {
         Step           = FixtureSteps.CreateGivenStep();
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, Step);
     });
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
Example #3
0
 void Ex03()
 {
     Given("GivenStep that has an arrangement that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateGivenStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step);
     });
     Given("a result of GivenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Failed(new Exception()).Build()));
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
    void Ex06()
    {
        Formatter.FormatFixtureStep(FixtureSteps.CreateGivenStep(Description));
        FormattedDescription = Formatter.FormatFixtureStep(FixtureSteps.CreateGivenStep(Description));

        Expect("the first line indent of the formatted description should be '        '(8 spaces)", () => FormattedDescription.FirstLineIndent == "        ");
        Expect("the line count of the formatted description should be 1", () => FormattedDescription.Lines.Count() == 1);
        Expect("the first element of the formatted description line should be the description of GivenStep", () => FormattedDescription.Lines.ElementAt(0) == Description);
        Expect("the line indent of the formatted description should be '        '(8spaces)", () => FormattedDescription.LineIndent == "        ");
        Expect("the items of the formatted description should be empty", () => !FormattedDescription.Items.Any());
    }
 void Ex02()
 {
     Given("async GivenStep that has an arrangement that throws an exception", () =>
     {
         Step = FixtureSteps.CreateGivenStep(async() =>
         {
             await Task.Delay(100);
             throw new Exception();
         });
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
    void Ex01()
    {
        var givenStepCompleted = false;

        Given("async GivenStep that has an arrangement that does not throw any exceptions", () =>
        {
            Step = FixtureSteps.CreateGivenStep(async() =>
            {
                await Task.Delay(100);
                givenStepCompleted = true;
            });
            ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
        });
        When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
        Then("the given GivenStep should be awaited", () => givenStepCompleted);
        Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
    }
Example #7
0
    void Ex03()
    {
        When("the result of GivenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep("Given")).Build()));
        When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep("When 1")).Build()));
        When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep("When 2")).Build()));
        When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep("When 3")).Build()));
        When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep("Then 1")).Build()));
        When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep("Then 2")).Build()));
        When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep("When 4")).Build()));
        When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep("When 5")).Build()));
        When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep("Then 3")).Build()));
        When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep("Then 4")).Build()));
        When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep("Then 5")).Build()));

        var latestGivenSteps = Results.GetLatestStepResultsOf <GivenStep>();

        Then("the count of the latest results of GivenStep should be 1", () => latestGivenSteps.Count() == 1);
        Then("the description of the latest result of GivenStep should be the specified description", () => latestGivenSteps.ElementAt(0).Step.Description == "Given");

        var latestWhenSteps = Results.GetLatestStepResultsOf <WhenStep>();

        Then("the count of the latest results of WhenStep should be 2", () => latestWhenSteps.Count() == 2);
        Then("the description of the latest result of WhenStep(1st) should be the specified description", () => latestWhenSteps.ElementAt(0).Step.Description == "When 5");
        Then("the description of the latest result of WhenStep(2nd) should be the specified description", () => latestWhenSteps.ElementAt(1).Step.Description == "When 4");

        var latestThenSteps = Results.GetLatestStepResultsOf <ThenStep>();

        Then("the count of the latest results of ThenStep should be 3", () => latestThenSteps.Count() == 3);
        Then("the description of the latest result of ThenStep(1st) should be the specified description", () => latestThenSteps.ElementAt(0).Step.Description == "Then 5");
        Then("the description of the latest result of ThenStep(2nd) should be the specified description", () => latestThenSteps.ElementAt(1).Step.Description == "Then 4");
        Then("the description of the latest result of ThenStep(3rd) should be the specified description", () => latestThenSteps.ElementAt(2).Step.Description == "Then 3");

        var latestExpectSteps = Results.GetLatestStepResultsOf <ExpectStep>();

        Then("the count of the latest results of ExpectStep should be 0", () => !latestExpectSteps.Any());
    }
Example #8
0
 void Ex01()
 {
     When("the result of GivenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Build()));
     When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
     When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Build()));
     When("the result of WhenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
     When("the result of ThenStep is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Build()));
     Then("the collection should not have the result of ExpectStep", () => !Results.Has(typeof(ExpectStep)));
     Then("the collection should have the result of GivenStep", () => Results.Has(typeof(GivenStep)));
     Then("the collection should have the result of WhenStep", () => Results.Has(typeof(WhenStep)));
     Then("the collection should have the result of ThenStep", () => Results.Has(typeof(ThenStep)));
     Then("the collection should have the result of GivenStep, WhenStep, and ThenStep", () => Results.Has(typeof(GivenStep), typeof(WhenStep), typeof(ThenStep)));
 }
Example #9
0
 void Ex08()
 {
     When("the result of GivenStep that has a Ready status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Ready().Build()));
     When("the result of ExpectStep that has a Failed status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Failed(new Exception()).Build()));
     When("the result of WhenStep that has a Passed status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Passed().Build()));
     When("the result of WhenStep that has a Failed status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build()));
     When("the result of WhenStep that has a Pending status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build()));
     When("the result of ThenStep that has a Passed is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Passed().Build()));
     When("the result of ExpectStep that has a Ready status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Ready().Build()));
     When("the result of WhenStep that has a Ready status is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Ready().Build()));
     When("the result of ThenStep that has a Failed is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Failed(new Exception()).Build()));
     Then("the value that indicates whether the latest result of GivenStep has Ready status should be true", () => Results.HasStatusAtLatest <GivenStep>(FixtureStepStatus.Ready));
     Then("the value that indicates whether the latest result of GivenStep has Passed status should be false", () => !Results.HasStatusAtLatest <GivenStep>(FixtureStepStatus.Passed));
     Then("the value that indicates whether the latest result of WhenStep has Passed status should be false", () => !Results.HasStatusAtLatest <WhenStep>(FixtureStepStatus.Passed));
     Then("the value that indicates whether the latest result of WhenStep has Ready status should be true", () => Results.HasStatusAtLatest <WhenStep>(FixtureStepStatus.Ready));
     Then("the value that indicates whether the latest result of ThenStep has Failed status should be true", () => Results.HasStatusAtLatest <ThenStep>(FixtureStepStatus.Failed));
     Then("the value that indicates whether the latest result of ThenStep has Passed status should be false", () => !Results.HasStatusAtLatest <ThenStep>(FixtureStepStatus.Passed));
     Then("the value that indicates whether the latest result of ExpectStep has Failed should be false", () => !Results.HasStatusAtLatest <ExpectStep>(FixtureStepStatus.Failed));
     Then("the value that indicates whether the latest result of ExpectStep has Ready should be true", () => Results.HasStatusAtLatest <ExpectStep>(FixtureStepStatus.Ready));
 }
Example #10
0
    void Ex06()
    {
        var targetException = new Exception();

        When("the result of GivenStep that has an exception that is not a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Failed(new Exception()).Build()));
        When("the result of ExpectStep that has a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Failed(targetException).Build()));
        When("the result of WhenStep that has a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(targetException).Build()));
        When("the result of WhenStep that has a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(targetException).Build()));
        When("the result of ThenStep that has an exception that is not a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Failed(new Exception()).Build()));
        When("the result of ThenStep that has an exception that is not a target exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Failed(new Exception()).Build()));
        When("the result of ExpectStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Passed().Build()));
        When("the collection clears the exception of the result the exception of which is equal to the target exception", () => Results.ClearException(targetException));
        Then("the exception of the result of GivenStep should not be cleared", () => Results.HasExceptionAt <GivenStep>());
        Then("all status of the result of GivenStep should not be Passed", () => Results.Where(r => r.Step.GetType() == typeof(GivenStep)).Any(r => r.Status != FixtureStepStatus.Passed));
        Then("the exception of the result of WhenStep should be cleared", () => !Results.HasExceptionAt <WhenStep>());
        Then("all status of the result of WhenStep should be Passed", () => Results.Where(r => r.Step.GetType() == typeof(WhenStep)).All(r => r.Status == FixtureStepStatus.Passed));
        Then("the exception of the result of ThenStep should not be cleared", () => Results.HasExceptionAt <ThenStep>());
        Then("all status of the result of GivenStep should not be Passed", () => Results.Where(r => r.Step.GetType() == typeof(ThenStep)).Any(r => r.Status != FixtureStepStatus.Passed));
        Then("the exception of the result of ExpectStep should be cleared", () => !Results.HasExceptionAt <ExpectStep>());
        Then("all status of the result of ExpectStep should be Passed", () => Results.Where(r => r.Step.GetType() == typeof(ExpectStep)).All(r => r.Status == FixtureStepStatus.Passed));
    }
Example #11
0
    void Ex05()
    {
        var whenException = new Exception();
        var thenException = new Exception();

        When("the result of GivenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Build()));
        When("the result of ExpectStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Failed(new Exception()).Build()));
        When("the result of WhenStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build()));
        When("the result of WhenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
        When("the result of WhenStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(whenException).Build()));
        When("the result of WhenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
        When("the result of ThenStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Failed(thenException).Build()));
        When("the result of ExpectStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Build()));
        Then("the exception of the latest result of GivenStep should be null", () => Results.GetLatestExceptionAt <GivenStep>() == null);
        Then("the exception of the latest result of WhenStep should be the specified last exception", () => Results.GetLatestExceptionAt <WhenStep>() == whenException);
        Then("the exception of the latest result of ThenStep should be the specified last exception", () => Results.GetLatestExceptionAt <ThenStep>() == thenException);
        Then("the exception of the latest result of ExpectStep should be null", () => Results.GetLatestExceptionAt <ExpectStep>() == null);
    }
Example #12
0
 void Ex05()
 {
     Given("ExpectStep that has an assertion that returns true", () =>
     {
         Step           = FixtureSteps.CreateExpectStep(() => true);
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step);
     });
     Given("a result of GivenStep that does not have Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Ready().Build()));
     When("the given ExpectStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
Example #13
0
 void Ex14()
 {
     Given("ThenStep that has an assertion without Exception that returns true", () =>
     {
         Step           = FixtureSteps.CreateThenStep(() => true);
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
     });
     Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build()));
     Given("a result of ThenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Pending().Build()));
     Given("a result of WhenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Passed().Build()));
     When("the given ThenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
Example #14
0
 void Ex10()
 {
     Given("ThenStep that has an assertion with Exception that returns boolean", () => Step = FixtureSteps.CreateThenStep(new Action <Exception>(exc => throw new Exception())));
     Given("a result of GivenStep that does not have an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build()));
     When("the given ThenStep is run", () => RunnerOf(Step).Run(StepResults).Build());
     Then("the status of the result of the latest WhenStep should be Passed", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Status == FixtureStepStatus.Passed);
     Then("the exception of the result of the latest WhenStep should be null", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Exception == null);
 }
Example #15
0
 void Ex01()
 {
     Expect("the step runner of GivenStep should be GivenStepRunner", () => StepRunnerFactory.Create(FixtureSteps.CreateGivenStep()).GetType() == typeof(GivenStepRunner));
     Expect("the step runner of WhenStep should be WhenStepRunner", () => StepRunnerFactory.Create(FixtureSteps.CreateWhenStep()).GetType() == typeof(WhenStepRunner));
     Expect("the step runner of ThenStep should be ThenStepRunner", () => StepRunnerFactory.Create(FixtureSteps.CreateThenStep()).GetType() == typeof(ThenStepRunner));
     Expect("the step runner of ExpectStep should be ExpectStepRunner", () => StepRunnerFactory.Create(FixtureSteps.CreateExpectStep()).GetType() == typeof(ExpectStepRunner));
 }
Example #16
0
 void Ex04()
 {
     When("the result of GivenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Build()));
     When("the result of ExpectStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Failed(new Exception()).Build()));
     When("the result of WhenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
     When("the result of WhenStep that has an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build()));
     When("the result of WhenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Build()));
     When("the result of ThenStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Build()));
     When("the result of ExpectStep that does not have an exception is added", () => Results.Add(FixtureStepResult.Of(FixtureSteps.CreateExpectStep()).Build()));
     Then("the value that indicates whether the latest result of GivenStep has an exception should be false", () => !Results.HasLatestExceptionAt <GivenStep>());
     Then("the value that indicates whether the latest result of WhenStep has an exception should be true", () => Results.HasLatestExceptionAt <WhenStep>());
     Then("the value that indicates whether the latest result of ThenStep has an exception should be false", () => !Results.HasLatestExceptionAt <ThenStep>());
     Then("the value that indicates whether the latest result of ExpectStep has an exception should be false", () => !Results.HasLatestExceptionAt <ExpectStep>());
 }
 void Ex09()
 {
     Given("WhenStep that has an action that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateWhenStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
     });
     Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build()));
     Given("a result of ThenStep that has Pending", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Pending().Build()));
     Given("a result of WhenStep that does not have Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Passed().Build()));
     When("the given WhenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
Example #18
0
 void Ex02()
 {
     Given("GivenStep that has an arrangement that does not throw any exceptions", () => Step = FixtureSteps.CreateGivenStep(() => { }));
     Given("a result of ThenStep", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Passed().Build()));
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then("InvalidFixtureStepException should be thrown", exc => exc.GetType() == typeof(InvalidFixtureStepException));
 }