RunSetUp() public method

Run SetUp on this level.
public RunSetUp ( TestExecutionContext context ) : void
context TestExecutionContext The execution context to use for running.
return void
Exemplo n.º 1
0
        public void SuccessfulThenFailingSetupShouldLetExceptionBubbleUpUnwrapped()
        {
            var item = new SetUpTearDownItem(Success.Concat(Failure).ToList(), Empty);

            Assert.Throws<InvalidOperationException>(() => item.RunSetUp(_context));
            Assert.That(_testObject.SuccessfulAsyncMethodRuns, Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void SuccessfulSetup()
        {
            var item = new SetUpTearDownItem(Success.ToList(), Empty);
            item.RunSetUp(_context);

            Assert.That(_testObject.SuccessfulAsyncMethodRuns, Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public void SuccessfulThenFailingTeardownShouldRecordFailureInTestContext()
        {
            var item = new SetUpTearDownItem(Empty, Success.Concat(Failure).ToList());

            item.RunSetUp(_context);
            item.RunTearDown(_context);

            Assert.That(_context.CurrentResult.ResultState, Is.EqualTo(ResultState.Error));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs a OneTimeSetUpCommand for a suite
        /// </summary>
        /// <param name="innerCommand">The inner command to which the command applies</param>
        /// <param name="setUpTearDown">A SetUpTearDownList for use by the command</param>
        public OneTimeSetUpCommand(TestCommand innerCommand, SetUpTearDownItem setUpTearDown)
            : base(innerCommand)
        {
            Guard.ArgumentValid(Test is TestSuite && Test.Type != null,
                                "OneTimeSetUpCommand must reference a TestFixture or SetUpFixture", nameof(innerCommand));

            BeforeTest = (context) =>
            {
                setUpTearDown.RunSetUp(context);
            };
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SetUpTearDownCommand"/> class.
        /// </summary>
        /// <param name="innerCommand">The inner command.</param>
        /// <param name="setUpTearDown">List of setup/teardown items</param>
        public SetUpTearDownCommand(TestCommand innerCommand, SetUpTearDownItem setUpTearDown)
            : base(innerCommand)
        {
            Guard.ArgumentValid(innerCommand.Test is TestMethod, "SetUpTearDownCommand may only apply to a TestMethod", "innerCommand");
            Guard.OperationValid(Test.TypeInfo != null, "TestMethod must have a non-null TypeInfo");
            Guard.ArgumentNotNull(setUpTearDown, nameof(setUpTearDown));

            BeforeTest = (context) =>
            {
                setUpTearDown.RunSetUp(context);
            };

            AfterTest = (context) =>
            {
                setUpTearDown.RunTearDown(context);
            };
        }
Exemplo n.º 6
0
        public void FailingSetupShouldLetExceptionBubbleUpUnwrapped()
        {
            var item = new SetUpTearDownItem(Failure.ToList(), Empty);

            Assert.Throws<InvalidOperationException>(() => item.RunSetUp(_context));
        }