Esempio n. 1
0
    private FixtureResult RunCore(IFixtureStepRunnerFactory stepRunnerFactory, FixtureResult.Builder result)
    {
        var fixtureInstance = CreateFixtureInstance();

        if (fixtureInstance is null)
        {
            throw new FixtureInstanceNotInstantiateException($"The instance of {FixtureDescriptor.Name} is not instantiate.");
        }

        return(fixtureInstance is IFixtureSteppable fixtureSteppable?RunCore(fixtureInstance, fixtureSteppable, stepRunnerFactory, result) : RunCore(fixtureInstance, result));
    }
Esempio n. 2
0
    /// <summary>
    /// Runs a fixture with the specified filter, step runner factory,
    /// and a value that indicates whether to run a fixture in parallel.
    /// </summary>
    /// <param name="filter">
    /// The filter that determines whether to run a fixture.
    /// </param>
    /// <param name="stepRunnerFactory">
    /// The factory to create a step runner.
    /// </param>
    /// <param name="parallel">
    /// <c>true</c> if a fixture is run in parallel; otherwise, <c>false</c>.
    /// </param>
    /// <returns>
    /// The result of a fixture running if a fixture can be run; otherwise, <c>null</c>.
    /// </returns>
    protected virtual FixtureResult?Run(IFixtureFilter?filter, IFixtureStepRunnerFactory stepRunnerFactory, bool parallel)
    {
        if (!CanRun(filter))
        {
            return(null);
        }

        var startTime = DateTime.UtcNow;

        OnFixtureRunning(new FixtureRunEventArgs(FixtureResult.Of(FixtureDescriptor).StartAt(startTime).Running()));
        var result = RunCore(startTime, filter, stepRunnerFactory, parallel);

        OnFixtureRun(new FixtureRunEventArgs(result));

        return(result);
    }
Esempio n. 3
0
    private FixtureResult RunCore(DateTime startTime, IFixtureFilter?filter, IFixtureStepRunnerFactory stepRunnerFactory, bool parallel)
    {
        var result = FixtureResult.Of(FixtureDescriptor).StartAt(startTime);

        try
        {
            var aroundFixtureAttributes = RetrieveAroundFixtureAttributes().ToList();
            aroundFixtureAttributes.ForEach(attribute => attribute.OnFixtureRunning(FixtureContext.Of(FixtureDescriptor)));
            try
            {
                return(Run(startTime, filter, stepRunnerFactory, parallel));
            }
            finally
            {
                aroundFixtureAttributes.ForEach(attribute => attribute.OnFixtureRun(FixtureContext.Of(FixtureDescriptor)));
            }
        }
        catch (Exception exc)
        {
            return(RecordEndTime(result).Failed(exc));
        }
    }
Esempio n. 4
0
 /// <summary>
 /// Runs a fixture with the specified start time, filter, step runner factory,
 /// and a value that indicates whether to run a fixture in parallel.
 /// </summary>
 /// <param name="startTime">The start time at which a fixture is run.</param>
 /// <param name="filter">
 /// The filter that determines whether to run a fixture.
 /// </param>
 /// <param name="stepRunnerFactory">
 /// The factory to create a step runner.
 /// </param>
 /// <param name="parallel">
 /// <c>true</c> if a fixture is run in parallel; otherwise, <c>false</c>.
 /// </param>
 /// <returns>
 /// The result of a fixture running.
 /// </returns>
 protected abstract FixtureResult Run(DateTime startTime, IFixtureFilter?filter, IFixtureStepRunnerFactory stepRunnerFactory, bool parallel);
Esempio n. 5
0
 private FixtureResult Run(IFixtureStepRunnerFactory stepRunnerFactory, FixtureResult.Builder result)
 => CanRunInSta(FixtureMethod) ? RunInSta(() => RunCore(stepRunnerFactory, result)) : RunCore(stepRunnerFactory, result);
Esempio n. 6
0
 /// <summary>
 /// Runs a fixture with the specified start time, filter, step runner factory,
 /// and a value that indicates whether to run a fixture in parallel.
 /// </summary>
 /// <param name="startTime">The start time at which a fixture is run.</param>
 /// <param name="filter">
 /// The filter that determines whether to run a fixture.
 /// </param>
 /// <param name="stepRunnerFactory">
 /// The factory to create a step runner.
 /// </param>
 /// <param name="parallel">
 /// <c>true</c> if a fixture is run in parallel; otherwise, <c>false</c>.
 /// </param>
 /// <returns>
 /// The result of a fixture running.
 /// </returns>
 /// <exception cref="FixtureInstanceNotInstantiateException">
 /// The instance of the fixture is not instantiate.
 /// </exception>
 protected override FixtureResult Run(DateTime startTime, IFixtureFilter?filter, IFixtureStepRunnerFactory stepRunnerFactory, bool parallel)
 => Run(stepRunnerFactory, FixtureResult.Of(FixtureDescriptor).StartAt(startTime));
Esempio n. 7
0
    private FixtureResult RunCore(object fixtureInstance, IFixtureSteppable fixtureSteppable, IFixtureStepRunnerFactory stepRunnerFactory, FixtureResult.Builder result)
    {
        var fixtureStepper = new FixtureStepper(stepRunnerFactory);

        fixtureStepper.FixtureStepRunning += (_, e) => OnFixtureStepRunning(e);
        fixtureStepper.FixtureStepRun     += (_, e) => OnFixtureStepRun(e);
        fixtureSteppable.Stepper           = fixtureStepper;

        RunCore(fixtureInstance);
        return(RecordEndTime(result).FinishedWith(fixtureStepper.Results));
    }
Esempio n. 8
0
 public FixtureStepRunnerFactorySpec()
 {
     StepRunnerFactory = new FixtureStepRunnerFactory();
 }