protected virtual void AfterExecutingChildren()
            {
                var context = InitContext;
                var runner  = (DefaultTestRunner)context.TestRunnerEvents;

                if (Unit == null)
                {
                    Result.Done(Unit, runner.Options);
                    return;
                }

                var result = Result;

                if (Unit.SetUpError != null)
                {
                    result.SetFailed(Unit.SetUpError);
                    result.Reason = "Problem setting up the test";
                }
                result.Done(Unit, runner.Options);
                Unit.NotifyFinished(runner, result);
                Safely.Dispose(context);

                if (Parent != null)
                {
                    Parent.Result.Children.Add(Result);
                }
            }
Exemple #2
0
        void ITestCaseFilter.RunTest(TestExecutionContext testContext, Action <TestExecutionContext> next)
        {
            var filter = _provider.CreateFilter(testContext);

            filter.BeforeExecuting(testContext);
            next(testContext);
            filter.AfterExecuting(testContext);

            Safely.Dispose(filter);
        }
Exemple #3
0
            static IEnumerable <TKey> LateBoundKVP(object actual, MethodInfo enumeratorMethod, PropertyInfo pi)
            {
                // We have to invoke the enumerator correspoding to the interface
                // we selected.  It isn't sufficient to just enumerate `actual' directly
                // because it could return some other object type.
                var e = (IEnumerator)enumeratorMethod.Invoke(actual, null);

                while (e.MoveNext())
                {
                    yield return((TKey)pi.GetValue(e.Current));
                }
                Safely.Dispose(e);
            }
Exemple #4
0
            public override bool Matches(IEnumerable actual)
            {
                if (actual == null)
                {
                    return(false);
                }

                var enumerator = actual.GetEnumerator();

                try {
                    if (enumerator.MoveNext())
                    {
                        return(false);
                    }
                    return(true);
                } finally {
                    Safely.Dispose(enumerator);
                }
            }