Beispiel #1
0
        /// <summary>
        /// Mark the scenario as failed if the match failed. If it passed _dont_ mark scenario as having been run
        /// as this could be called from any step( given, check, when...)
        /// </summary>
        private void FailIfNotPassed <T>(Boolean passed, T actual, IMatcher <T> matcher,
                                         IMatchDiagnostics diagnostics)
        {
            MarkLastStepPassed(passed);
            if (!passed)
            {
                Passed(false);

                var desc = new Description();
                desc.Child("Steps were", StepsToString());
                desc.Child("expected", matcher);
                if (actual is String)
                {
                    desc.Child("but was", "'" + actual + "'");
                }
                else
                {
                    desc.Child("but was", actual);
                }
                desc.Text("==== Diagnostics ====");
                desc.Child(diagnostics);

                TestFirstAssert.Fail(Environment.NewLine + desc.ToString());
            }
        }
Beispiel #2
0
        private void GenerateAndThrowFailMsg(Object actual, IMatcher matcher, MatchDiagnostics diag, Object label)
        {
            var desc = new Description();

            if (label != null)
            {
                desc.Child("for", label);
            }
            Expect.PrintExpectButGot(desc, actual, matcher);
            desc.Text("==== Diagnostics ====");
            desc.Child(diag);
            TestFirstAssert.Fail(Environment.NewLine + desc.ToString());
        }