Example #1
0
        public void RunStepAndVerifyOutcome_ExecutionWithIncorrectOutcome()
        {
            bool        ran     = false;
            TestContext context = null;

            AssertionFailure[] failures = AssertionHelper.Eval(() =>
            {
                context = TestStep.RunStepAndVerifyOutcome("Abc", () =>
                {
                    ran = true;
                    Assert.Inconclusive();
                }, TestOutcome.Passed);
            }, AssertionFailureBehavior.CaptureAndContinue);

            Assert.AreEqual(1, failures.Length);
            Assert.AreEqual("The test step did not produce the expected outcome.", failures[0].Description);
            Assert.AreEqual("Expected Outcome", failures[0].LabeledValues[0].Label);
            Assert.AreEqual("passed", failures[0].LabeledValues[0].FormattedValue.ToString());
            Assert.AreEqual("Actual Outcome", failures[0].LabeledValues[1].Label);
            Assert.AreEqual("inconclusive", failures[0].LabeledValues[1].FormattedValue.ToString());

            Assert.IsTrue(ran, "Verify that the step ran.");
            Assert.AreEqual(TestOutcome.Inconclusive, context.Outcome,
                            "Verify that the step has the expected outcome.");
            Assert.AreEqual("Abc", context.TestStep.Name);
            Assert.Contains(context.TestStep.CodeElement.CodeReference.MemberName, "RunStepAndVerifyOutcome_ExecutionWithIncorrectOutcome");
            Assert.IsFalse(context.TestStep.IsTestCase);
        }