Наследование: IDisposable, ISpecificationEngine
Пример #1
0
        private SpecificationEngine buildBatchedEngine(string tracingStyle)
        {
            IBatchObserver     batchObserver     = new BatchObserver();
            IExecutionObserver executionObserver = new NulloObserver();

            if ("TeamCity" == tracingStyle)
            {
                batchObserver     = new TeamCityBatchObserver(batchObserver);
                executionObserver = new TeamCityExecutionObserver();
            }

            var executionMode = new BatchExecutionMode(batchObserver);
            var runner        = new SpecRunner(executionMode, _system, executionObserver);

            var engine = new SpecificationEngine(
                _system, runner, executionObserver);

            _controller = new BatchController(engine, batchObserver);

            _disposables.Add(engine);

            EventAggregator.Messaging.AddListener(_controller);

            return(engine);
        }
Пример #2
0
        private SpecificationEngine buildUserInterfaceEngine()
        {
            var observer          = new UserInterfaceObserver();
            var executionObserver = new UserInterfaceExecutionObserver();

            var runner = new SpecRunner(new UserInterfaceExecutionMode(observer), _running.System, executionObserver);


            var engine = new SpecificationEngine(_running.System, runner, executionObserver);

            _controller = new EngineController(engine, observer, runner);

            // Super hokey, but we need some way to feed the spec started
            // event up to EngineController
            // TODO -- maybe pull the IExecutionQueue concept from 1-2 back out
            executionObserver.Controller = (EngineController)_controller;


            _disposables.Add(observer);
            _disposables.Add(engine);

            EventAggregator.Messaging.AddListener(_controller);

            return(engine);
        }
Пример #3
0
        public void Start(Project project)
        {
            if (_running != null)
            {
                Console.WriteLine($"AGENT: Trying to start specification runner for {_running.GetType().Name} at {project.ProjectPath} and port {project.Port}");
            }

            Project.CurrentProject = project;


            _project = project;

            Type systemType = null;



            try
            {
                if (_running == null)
                {
                    buildRunningSystem();
                }

                if (project.Mode == EngineMode.ExportOnly)
                {
                    EventAggregator.SendMessage(_running.RecycledMessage);
                    return;
                }


                _engine = project.Mode == EngineMode.Interactive
                    ? buildUserInterfaceEngine()
                    : buildBatchedEngine(project.TracingStyle);


                _engine.Start(project.StopConditions);


                ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath);
            }
            catch (Exception e)
            {
                StorytellerAgent.LogFailure(e);

                ConsoleWriter.Write(ConsoleColor.Red, e.ToString());

                var message = new SystemRecycled
                {
                    error   = e.ToString(),
                    success = false,
                };

                EventAggregator.SendMessage(message);
            }
        }
Пример #4
0
        public void Start(Project project)
        {
            if (_system != null)
            {
                Console.WriteLine($"AGENT: Trying to start specification runner for {_system.GetType().Name} at {project.ProjectPath} and port {project.Port}");
            }

            Project.CurrentProject = project;


            _project = project;

            Type systemType = null;

            try
            {
                if (_system == null)
                {
                    systemType = _project.DetermineSystemType();
                    _system    = Activator.CreateInstance(systemType).As <ISystem>();
                    _disposables.Add(_system);
                }


                _specExpiration = new SpecExpiration();

                _engine = project.Mode == EngineMode.Interactive
                    ? buildUserInterfaceEngine()
                    : buildBatchedEngine(project.TracingStyle);


                _engine.Start(project.StopConditions);


                ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath);
            }
            catch (Exception e)
            {
                ConsoleWriter.Write(ConsoleColor.Red, e.ToString());

                var message = new SystemRecycled
                {
                    error   = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }
        }
Пример #5
0
        public void Start(EngineMode mode, Project project, MarshalByRefObject remoteListener)
        {
            Project.CurrentProject = project;

            EventAggregator.Start((IRemoteListener) remoteListener);

            _project = project;

            Type systemType = null;

            try
            {
                systemType = _project.DetermineSystemType();
                _system = Activator.CreateInstance(systemType).As<ISystem>();
                _services.Add(_system);

                var timeZone = new MachineTimeZoneContext();
                var clock = new Clock();
                var systemTime = new SystemTime(clock, timeZone);
                _specExpiration = new SpecExpiration(systemTime);

                if (mode == EngineMode.Interactive)
                {
                    _engine = buildUserInterfaceEngine();
                }
                else
                {
                    _engine = buildBatchedEngine(project.TracingStyle);
                }

                _engine.Start(project.StopConditions);

            }
            catch (Exception e)
            {
                var message = new SystemRecycled
                {
                    error = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
        }
Пример #6
0
        public void Start(Project project)
        {
            if (_running != null)
            {
                Console.WriteLine($"AGENT: Trying to start specification runner for {_running.GetType().Name} at {project.ProjectPath} and port {project.Port}");
            }

            Project.CurrentProject = project;


            _project = project;


            try
            {
                _engine = buildUserInterfaceEngine();


                _engine.Start(project.StopConditions);


                ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath);
            }
            catch (Exception e)
            {
                StorytellerAgent.LogFailure(e);

                ConsoleWriter.Write(ConsoleColor.Red, e.ToString());

                var message = new SystemRecycled
                {
                    error   = e.ToString(),
                    success = false,
                };

                EventAggregator.SendMessage(message);
            }
        }
Пример #7
0
        private SpecificationEngine buildUserInterfaceEngine()
        {
            var observer = new UserInterfaceObserver();

            var runner = new SpecRunner(new UserInterfaceExecutionMode(observer), _system, _specExpiration);

            var executionObserver = new UserInterfaceExecutionObserver();
            var engine  = new SpecificationEngine(_system, runner, executionObserver);
            _controller = new EngineController(engine, observer, runner);

            // Super hokey, but we need some way to feed the spec started
            // event up to EngineController
            // TODO -- maybe pull the IExecutionQueue concept from 1-2 back out
            executionObserver.Controller = (EngineController) _controller;

            _services.Add(observer);
            _services.Add(engine);

            EventAggregator.Messaging.AddListener(_controller);

            return engine;
        }
Пример #8
0
        private SpecificationEngine buildBatchedEngine(string tracingStyle)
        {
            IBatchObserver batchObserver = new BatchObserver();
            IExecutionObserver executionObserver = new NulloObserver();

            if ("TeamCity" == tracingStyle)
            {
                batchObserver = new TeamCityBatchObserver(batchObserver);
                executionObserver = new TeamCityExecutionObserver();
            }

            var executionMode = new BatchExecutionMode(batchObserver);
            var runner = new SpecRunner(executionMode, _system, _specExpiration);

            var engine = new SpecificationEngine(
                _system, runner, executionObserver);

            _controller = new BatchController(engine, batchObserver);

            _services.Add(engine);

            EventAggregator.Messaging.AddListener(_controller);

            return engine;
        }
Пример #9
0
        public void Start(Project project)
        {
            if (_system != null)
            {
                Console.WriteLine($"AGENT: Trying to start specification runner for {_system.GetType().Name} at {project.ProjectPath} and port {project.Port}");
            }

            Project.CurrentProject = project;


            _project = project;

            Type systemType = null;

            try
            {
                if (_system == null)
                {
                    systemType = _project.DetermineSystemType();
                    _system = Activator.CreateInstance(systemType).As<ISystem>();
                    _disposables.Add(_system);
                }

                if (project.Mode == EngineMode.ExportOnly)
                {
                    var recycled = _system.Initialize(lib => { });
                    EventAggregator.SendMessage(recycled);
                    return;
                }


                _engine = project.Mode == EngineMode.Interactive
                    ? buildUserInterfaceEngine()
                    : buildBatchedEngine(project.TracingStyle);


                _engine.Start(project.StopConditions);


                ConsoleWriter.Write("AGENT: Specification running engine ready at " + project.ProjectPath);
            }
            catch (Exception e)
            {
                ConsoleWriter.Write(ConsoleColor.Red, e.ToString());

                var message = new SystemRecycled
                {
                    error = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }


        }