public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options)
    {
      IEnumerable<Result> results;
      listener.OnContextStart(context.GetInfo());
      Result result = Result.Pass();

      if (context.HasExecutableSpecifications)
      {
        result = context.EstablishContext();
      }

      if (result.Passed)
      {
        results = RunSpecifications(context, listener, options);
      }
      else
      {
        results = FailSpecifications(context, listener, options, result);
      }

      if (context.HasExecutableSpecifications)
      {
        result = context.Cleanup();
      }

      listener.OnContextEnd(context.GetInfo());

      return results;
    }
Esempio n. 2
0
        public IEnumerable <Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable <ISupplementSpecificationResults> resultSupplementers)
        {
            IEnumerable <Result> results;

            listener.OnContextStart(context.GetInfo());
            Result result = Result.Pass();

            if (context.HasExecutableSpecifications)
            {
                result = context.EstablishContext();
            }

            if (result.Passed)
            {
                results = RunSpecifications(context, listener, options, resultSupplementers);
            }
            else
            {
                results = FailSpecifications(context, listener, options, result, resultSupplementers);
            }

            if (context.HasExecutableSpecifications)
            {
                result = context.Cleanup();
                foreach (var cleanup in globalCleanups)
                {
                    cleanup.AfterContextCleanup();
                }
            }

            listener.OnContextEnd(context.GetInfo());

            return(results);
        }
    public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable<ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable<ISupplementSpecificationResults> resultSupplementers)
    {
      IEnumerable<Result> results;
      listener.OnContextStart(context.GetInfo());
      Result result = Result.Pass();

      if (context.HasExecutableSpecifications)
      {
        result = context.EstablishContext();
      }

      if (result.Passed)
      {
        results = RunSpecifications(context, listener, options, resultSupplementers);
      }
      else
      {
        results = FailSpecifications(context, listener, result, resultSupplementers);
      }

      if (context.HasExecutableSpecifications)
      {
        result = context.Cleanup();
        foreach (var cleanup in globalCleanups)
        {
          cleanup.AfterContextCleanup();
        }
      }

      listener.OnContextEnd(context.GetInfo());

      return results;
    }
Esempio n. 4
0
        public IEnumerable <Result> Run(
            Context context,
            ISpecificationRunListener listener,
            RunOptions options,
            IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups,
            IEnumerable <ISupplementSpecificationResults> resultSupplementers)
        {
            var results = new List <Result>();

            listener.OnContextStart(context.GetInfo());

            foreach (var specification in context.Specifications)
            {
                var result = Result.Pass();

                if (specification.IsExecutable)
                {
                    result = context.EstablishContext();
                }

                if (result.Passed)
                {
                    var runner = new SpecificationRunner(listener, resultSupplementers);
                    result = runner.Run(specification);
                }
                else
                {
                    results = FailSpecification(listener, specification, result);
                }

                if (specification.IsExecutable)
                {
                    var cleanupResult = context.Cleanup();

                    if (result.Passed && !cleanupResult.Passed)
                    {
                        result = cleanupResult;
                    }

                    foreach (var cleanup in globalCleanups)
                    {
                        cleanup.AfterContextCleanup();
                    }
                }

                results.Add(result);
            }

            listener.OnContextEnd(context.GetInfo());

            return(results);
        }
Esempio n. 5
0
        private void OnListenEvent(string value)
        {
            using (var stringReader = new StringReader(value)) {
                XDocument doc     = XDocument.Load(stringReader);
                XElement  element = doc.XPathSelectElement("/listener/*");

                switch (element.Name.ToString())
                {
                case "onassemblystart":
                    _runListener.OnAssemblyStart(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblystart/*").ToString()));
                    break;

                case "onassemblyend":
                    _runListener.OnAssemblyEnd(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblyend/*").ToString()));
                    break;

                case "onrunstart":
                    _runListener.OnRunStart();
                    break;

                case "onrunend":
                    _runListener.OnRunEnd();
                    break;

                case "oncontextstart":
                    _runListener.OnContextStart(ContextInfo.Parse(element.XPathSelectElement("//oncontextstart/*").ToString()));
                    break;

                case "oncontextend":
                    _runListener.OnContextEnd(ContextInfo.Parse(element.XPathSelectElement("//oncontextend/*").ToString()));
                    break;

                case "onspecificationstart":
                    _runListener.OnSpecificationStart(SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationstart/*").ToString()));
                    break;

                case "onspecificationend":
                    _runListener.OnSpecificationEnd(
                        SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationend/specificationinfo").ToString()),
                        Result.Parse(element.XPathSelectElement("//onspecificationend/result").ToString()));
                    break;

                case "onfatalerror":
                    _runListener.OnFatalError(ExceptionResult.Parse(element.XPathSelectElement("//onfatalerror/*").ToString()));
                    break;
                }
            }
        }
        public static void Run(this ISpecificationRunListener adapter, AssemblyInfo assemblyInfo,
                               SpecificationInfo specificationInfo, Result failure, ExceptionResult exceptionResult,
                               ContextInfo contexInfo)
        {
            adapter.OnAssemblyStart(assemblyInfo);
            adapter.OnAssemblyEnd(assemblyInfo);

            adapter.OnSpecificationStart(specificationInfo);
            adapter.OnSpecificationEnd(specificationInfo, failure);

            adapter.OnFatalError(exceptionResult);

            adapter.OnContextStart(contexInfo);
            adapter.OnContextEnd(contexInfo);

            adapter.OnRunStart();
            adapter.OnRunEnd();
        }
Esempio n. 7
0
        public IEnumerable <Result> Run(
            Context context,
            ISpecificationRunListener listener,
            RunOptions options,
            IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups,
            IEnumerable <ISupplementSpecificationResults> resultSupplementers)
        {
            listener.OnContextStart(context.GetInfo());

            var result = Result.Pass();

            if (context.HasExecutableSpecifications)
            {
                result = context.EstablishContext();
            }

            var results = result.Passed
                ? RunSpecifications(context, listener, options, resultSupplementers)
                : FailSpecifications(context, listener, result, resultSupplementers);

            if (context.HasExecutableSpecifications)
            {
                var cleanupResult = context.Cleanup();

                if (!cleanupResult.Passed)
                {
                    listener.OnFatalError(cleanupResult.Exception);
                }

                foreach (var cleanup in globalCleanups)
                {
                    cleanup.AfterContextCleanup();
                }
            }

            listener.OnContextEnd(context.GetInfo());

            return(results);
        }
Esempio n. 8
0
 public void OnContextEnd(ContextInfo context)
 {
     currentContext = null;
     runListener.OnContextEnd(context);
 }
    public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable<ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable<ISupplementSpecificationResults> resultSupplementers)
    {
      var results = new List<Result>();
      listener.OnContextStart(context.GetInfo());

      foreach (var specification in context.Specifications)
      {
        Result result = Result.Pass();

        if (specification.IsExecutable)
        {
          result = context.EstablishContext();
        }

        if (result.Passed)
        {
          var runner = new SpecificationRunner(listener, options, resultSupplementers);
          result = runner.Run(specification);
        }
        else
        {
            results = FailSpecification(listener, specification, result);
        }

        if (specification.IsExecutable)
        {
          var cleanupResult = context.Cleanup();

          if (result.Passed && !cleanupResult.Passed)
          {
            result = cleanupResult;
          }

          foreach (var cleanup in globalCleanups)
          {
            cleanup.AfterContextCleanup();
          }
        }

        results.Add(result);
      }

      listener.OnContextEnd(context.GetInfo());

      return results;
    }
 public void OnContextEnd(ContextInfo context)
 {
     _listener.OnContextEnd(context);
 }
Esempio n. 11
0
 public void OnContextEnd(Runner.ContextInfo context)
 {
     listener.OnContextEnd(new ContextInfo(context.Name, context.Concern, context.TypeName, context.Namespace, context.AssemblyName));
 }
 public override void OnContextEnd(ContextInfo context)
 {
     _listener.OnContextEnd(context);
     _testContext.LifecyclePhase = LifecyclePhases.Finishing;
 }
Esempio n. 13
0
 public virtual void OnContextEnd(ContextInfo contextInfo)
 {
     _runListener.OnContextEnd(contextInfo);
 }
    public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options)
    {
      var results = new List<Result>();
      listener.OnContextStart(context.GetInfo());

      foreach (var specification in context.Specifications)
      {
        Result result = Result.Pass();

        if (specification.IsExecutable)
        {
          result = context.EstablishContext();
        }

        if (result.Passed)
        {
          var runner = new SpecificationRunner(listener, options);
          result = runner.Run(specification);
        }

        if (specification.IsExecutable)
        {
          var cleanupResult = context.Cleanup();

          if (result.Passed && !cleanupResult.Passed)
          {
            result = cleanupResult;
          }
        }

        results.Add(result);
      }

      listener.OnContextEnd(context.GetInfo());

      return results;
    }