void Ex03()
    {
        var thenStepCompleted = false;

        Given("async ThenStep that has an assertion with Exception that does not throw any exceptions", () =>
        {
            Step = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ =>
            {
                await Task.Delay(100);
                thenStepCompleted = true;
            });
            ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
        });
        Given("async next ThenStep that asserts the Exception that is thrown at WhenStep", () =>
        {
            NextStep = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ =>
            {
                await Task.Delay(100);
                thenStepCompleted = true;
            });
            ExpectedNextResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, NextStep);
        });
        When("the given ThenStep is run", () =>
        {
            Result = RunnerOf(Step).Run(StepResults).Build();
            StepResults.Add(Result);
        });
        Then("the given ThenStep should be awaited", () => thenStepCompleted);
        Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);

        thenStepCompleted = false;
        When("the given next ThenStep is run", () => Result = RunnerOf(NextStep).Run(StepResults).Build());
        Then("the given next ThenStep should be awaited", () => thenStepCompleted);
        Then($"the result should be as follows:{ExpectedNextResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedNextResult);
    }
Beispiel #2
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));
 }
Beispiel #3
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);
 }
Beispiel #4
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);
 }
Beispiel #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);
 }
 public void AddStepResult(Step step)
 {
     if (!StepResults.Any(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value))
     {
         StepResults.Add(new StepResult(step));
     }
     else
     {
         var stepResult = StepResults.First(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value);
         stepResult.Attempts++;
     }
 }
 void Ex08()
 {
     Given("WhenStep that has an action that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateWhenStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, 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()));
     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);
 }
Beispiel #8
0
 void Ex13()
 {
     Given("ThenStep that has an assertion without Exception that returns true", () =>
     {
         Step           = FixtureSteps.CreateThenStep(() => true);
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, 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()));
     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);
 }
 public void AddStepResult(StepResult result)
 {
     StepResults.Add(result);
 }