Example #1
0
    void Ex04()
    {
        FormattedDescription = Formatter.FormatFixtureStep(FixtureSteps.CreateExpectStep(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 'Expect {the description of ExpectStep}'", () => FormattedDescription.Lines.ElementAt(0) == $"Expect {Description}");
        Expect("the line indent of the formatted description should be '       '(7 spaces)", () => FormattedDescription.LineIndent == "       ");
        Expect("the items of the formatted description should be empty", () => !FormattedDescription.Items.Any());
    }
 void Ex03()
 {
     Given("ExpectStep that has an action that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateExpectStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
     });
     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);
 }
 void Ex02()
 {
     Given("ExpectStep that has an assertion that returns true", () =>
     {
         Step           = FixtureSteps.CreateExpectStep(() => false);
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
    void Ex09()
    {
        Formatter.FormatFixtureStep(FixtureSteps.CreateExpectStep(Description));
        FormattedDescription = Formatter.FormatFixtureStep(FixtureSteps.CreateExpectStep(Description));

        Expect("the first line indent of the formatted description should be '       '(7 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 ExpectStep", () => FormattedDescription.Lines.ElementAt(0) == Description);
        Expect("the line indent of the formatted description should be '       '(7 spaces)", () => FormattedDescription.LineIndent == "       ");
        Expect("the items of the formatted description should be empty", () => !FormattedDescription.Items.Any());
    }
Example #5
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);
 }
 void Ex02()
 {
     Given("async ExpectStep that has an action that throws an exception", () =>
     {
         Step = FixtureSteps.CreateExpectStep(async() =>
         {
             await Task.Delay(100);
             throw new Exception();
         });
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
    void Ex01()
    {
        var expectStepCompleted = false;

        Given("async ExpectStep that has an action that does not throw any exceptions", () =>
        {
            Step = FixtureSteps.CreateExpectStep(async() =>
            {
                await Task.Delay(100);
                expectStepCompleted = true;
            });
            ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
        });
        When("the given ExpectStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
        Then("the given ExpectStep should be awaited", () => expectStepCompleted);
        Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
    }
Example #8
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>());
 }
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 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));
 }