Esempio n. 1
0
        public TArranged visitBeforeAll <TArranged>(BeforeAllElement <TArranged> element, TestPosition position)
        {
            CheckNotAlreadyPastDiscovery(element);

            TArranged result = default(TArranged);

            if (position.IsOnPathTo(_targetPosition))
            {
                _executingPastDiscovery = element;

                try
                {
                    try
                    {
                        result = element.Action();
                    }
                    catch (Exception e)
                    {
                        ReportError(position, e);
                    }

                    _setupResultAccumulator.AddSetupResult(position, result);
                }
                finally
                {
                    _executingPastDiscovery = null;
                }
            }

            return(result);
        }
Esempio n. 2
0
        public object GetSetupResultAt(TestPosition position)
        {
            if (!position.IsOnPathTo(_targetPosition))
            {
                throw new InvalidProgramException();
            }

            return(_setupResultAccumulator.InternalGetSetupResultAt(position));
        }
 public Exception GetErrorForPosition(TestPosition position)
 {
     if (_existingError != null && _existingErrorPosition != null && _existingErrorPosition.IsOnPathTo(position))
     {
         return(_existingError);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 4
0
        protected void ReportError(TestPosition position, Exception error)
        {
            _errorAccumulator.AddError(position, error);

            while (error != null &&
                   position != null &&
                   position.IsOnPathTo(_targetPosition))
            {
                _runningLock.PassAndWaitForTurn();
            }
        }
Esempio n. 5
0
        public void visitAfterAll(AfterAllElement element, TestPosition position)
        {
            CheckNotAlreadyPastDiscovery(element);

            if (position.IsOnPathTo(_targetPosition))
            {
                _setupResultAccumulator.AddCleanupAction(position, delegate {
                    _executingCleanup = element;
                    element.Action();
                    _executingCleanup = null;
                });
            }
        }