コード例 #1
0
 void Ex04()
 {
     Given("ThenStep that has an assertion with Exception that throws an exception", () =>
     {
         Step           = FixtureSteps.CreateThenStep(new Action <Exception>(exc => throw new Exception()));
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
    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);
    }
コード例 #3
0
ファイル: NoteStepRunnerSpec.cs プロジェクト: averrunci/Carna
 void Ex01()
 {
     Given("NoteStep", () =>
     {
         Step           = FixtureSteps.CreateNoteStep();
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.None, Step);
     });
     When("the given NoteStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 void Ex02()
 {
     Given("GivenStep that has an arrangement that throws an exception", () =>
     {
         Step           = FixtureSteps.CreateGivenStep(() => 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 Ex02()
 {
     Given("ThenStep that has tye type of an exception that is invalid", () =>
     {
         Step           = FixtureSteps.CreateThenStep <InvalidOperationException>();
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
コード例 #7
0
 void Ex02()
 {
     Given("WhenStep that has an action that is not completed within a time-out", () =>
     {
         Step           = FixtureSteps.CreateWhenStep(TimeSpan.FromMilliseconds(100), () => Thread.Sleep(200));
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
コード例 #8
0
 void Ex01()
 {
     Given("WhenStep that has an action that is completed within a time-out", () =>
     {
         Step           = FixtureSteps.CreateWhenStep(100, () => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
     });
     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);
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 void Ex03()
 {
     Given("ThenStep that has an assertion with Exception that does not throw any exception", () =>
     {
         Step           = FixtureSteps.CreateThenStep(exc => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
     });
     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);
 }
コード例 #11
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);
 }
コード例 #12
0
 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);
 }
コード例 #13
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);
 }
コード例 #14
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);
 }
コード例 #15
0
 void Ex04()
 {
     Given("async WhenStep that has an action that is not completed within a time-out", () =>
     {
         Step = FixtureSteps.CreateWhenStep(100, async() =>
         {
             await Task.Delay(200);
         });
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
コード例 #16
0
 void Ex02()
 {
     Given("async ThenStep that has an assertion with Exception that throws an exception", () =>
     {
         Step = FixtureSteps.CreateThenStep(async _ =>
         {
             await Task.Delay(100);
             throw new Exception();
         });
         ExpectedResult = FixtureStepResultAssertion.ForNotNullException(FixtureStepStatus.Failed, Step);
     });
     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);
 }
コード例 #17
0
    void Ex03()
    {
        var whenStepCompleted = false;

        Given("async WhenStep that has an action that is completed within a time-out", () =>
        {
            Step = FixtureSteps.CreateWhenStep(100, async() =>
            {
                await Task.Delay(50);
                whenStepCompleted = true;
            });
            ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
        });
        When("the given WhenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
        Then("the given WhenStep should be awaited", () => whenStepCompleted);
        Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
    }
コード例 #18
0
    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);
    }
    protected void Ex02()
    {
        Filter.Accept(Arg.Any <FixtureDescriptor>()).Returns(true);

        var result = Fixture.Run(Filter, new TestFixtures.SimpleFixtureStepRunnerFactory());

        Expect("the fixture method should be called", () => TestFixtures.CalledFixtureMethods.Count == 1 && TestFixtures.CalledFixtureMethods.Contains(TargetFixtureType));

        ExpectedFixtureDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute));
        Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor);
        ExpectedFixtureResult = FixtureResultAssertion.ForNullException(true, true, true, 1, 0, FixtureStatus.Passed);
        Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult);

        if (result is null)
        {
            return;
        }

        var stepResult = result.StepResults.ElementAt(0);

        ExpectedFixtureStepResult = FixtureStepResultAssertion.Of("Description", null, FixtureStepStatus.Passed, typeof(ExpectStep));
        Expect($"the result of the step should be as follows:{ExpectedFixtureStepResult.ToDescription()}", () => FixtureStepResultAssertion.Of(stepResult) == ExpectedFixtureStepResult);

        Expect("FixtureRunning event should be raised", () => FixtureRunningResult != null);

        ExpectedFixtureRunningDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute));
        Expect($"the descriptor of the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningDescriptor.ToDescription()}", () => FixtureRunningResult != null && FixtureDescriptorAssertion.Of(FixtureRunningResult.FixtureDescriptor) == ExpectedFixtureRunningDescriptor);
        ExpectedFixtureRunningResult = FixtureResultAssertion.ForNullException(true, false, false, 0, 0, FixtureStatus.Running);
        Expect($"the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningResult.ToDescription()}", () => FixtureRunningResult != null && FixtureResultAssertion.Of(FixtureRunningResult) == ExpectedFixtureRunningResult);

        Expect("FixtureRun event should be raised", () => FixtureRunResult != null);

        Expect("the result on FixtureRun event should be the result that is returned by Run method", () => FixtureRunResult == result);

        Expect("FixtureStepRunning event should be raised", () => FixtureStepRunningResult != null);

        ExpectedFixtureStepRunningResult = FixtureStepRunningResultAssertion.Of(stepResult.Step, true, false, false, null, FixtureStepStatus.Running);
        Expect("the result of the step on FixtureStepRunning event should be as follows", () => FixtureStepRunningResult != null && FixtureStepRunningResultAssertion.Of(FixtureStepRunningResult) == ExpectedFixtureStepRunningResult);

        Expect("FixtureStepRun event should be raised", () => FixtureStepRunResult != null);

        Expect("the result on FixtureStepRun event should be the result that is returned by Run method", () => FixtureStepRunResult == stepResult);
    }