private void InitializeExecutionMessageHandlers()
        {
            var activatorWrapper  = new ActivatorWrapper();
            var reflectionWrapper = new ReflectionWrapper();
            var assemblies        = new AssemblyLocater(new DirectoryWrapper(), new FileWrapper()).GetAllAssemblies();
            var assemblyLoader    = new AssemblyLoader(new AssemblyWrapper(), assemblies, reflectionWrapper, activatorWrapper);

            _stepRegistry = assemblyLoader.GetStepRegistry();
            var tableFormatter        = new TableFormatter(assemblyLoader, activatorWrapper);
            var classInstanceManager  = assemblyLoader.GetClassInstanceManager();
            var executionOrchestrator = new ExecutionOrchestrator(reflectionWrapper, assemblyLoader, activatorWrapper,
                                                                  classInstanceManager,
                                                                  new HookExecutor(assemblyLoader, reflectionWrapper, classInstanceManager),
                                                                  new StepExecutor(assemblyLoader, reflectionWrapper, classInstanceManager));

            this.executionStartingProcessor         = new ExecutionStartingProcessor(executionOrchestrator);
            this.executionEndingProcessor           = new ExecutionEndingProcessor(executionOrchestrator);
            this.specExecutionStartingProcessor     = new SpecExecutionStartingProcessor(executionOrchestrator);
            this.specExecutionEndingProcessor       = new SpecExecutionEndingProcessor(executionOrchestrator);
            this.scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator);
            this.scenarioExecutionEndingProcessor   = new ScenarioExecutionEndingProcessor(executionOrchestrator);
            this.stepExecutionStartingProcessor     = new StepExecutionStartingProcessor(executionOrchestrator);
            this.stepExecutionEndingProcessor       = new StepExecutionEndingProcessor(executionOrchestrator);
            this.executeStepProcessor           = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter);
            this.scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(assemblyLoader);
            this.specDataStoreInitProcessor     = new SpecDataStoreInitProcessor(assemblyLoader);
            this.suiteDataStoreInitProcessor    = new SuiteDataStoreInitProcessor(assemblyLoader);
        }
Пример #2
0
        private void InitializeExecutionMessageHandlers()
        {
            var tableFormatter       = new TableFormatter(this._assemblyLoader, this._activatorWrapper);
            var classInstanceManager = new ThreadLocal <object>(() =>
            {
                return(this._assemblyLoader.GetClassInstanceManager());
            });
            var executionInfoMapper   = new ExecutionInfoMapper(this._assemblyLoader, this._activatorWrapper);
            var executionOrchestrator = new ExecutionOrchestrator(this._reflectionWrapper, this._assemblyLoader,
                                                                  classInstanceManager.Value,
                                                                  new HookExecutor(this._assemblyLoader, this._reflectionWrapper, classInstanceManager.Value, executionInfoMapper),
                                                                  new StepExecutor(this._assemblyLoader, this._reflectionWrapper, classInstanceManager.Value));

            this.executionStartingProcessor         = new ExecutionStartingProcessor(executionOrchestrator);
            this.executionEndingProcessor           = new ExecutionEndingProcessor(executionOrchestrator);
            this.specExecutionStartingProcessor     = new SpecExecutionStartingProcessor(executionOrchestrator);
            this.specExecutionEndingProcessor       = new SpecExecutionEndingProcessor(executionOrchestrator);
            this.scenarioExecutionStartingProcessor = new ScenarioExecutionStartingProcessor(executionOrchestrator);
            this.scenarioExecutionEndingProcessor   = new ScenarioExecutionEndingProcessor(executionOrchestrator);
            this.stepExecutionStartingProcessor     = new StepExecutionStartingProcessor(executionOrchestrator);
            this.stepExecutionEndingProcessor       = new StepExecutionEndingProcessor(executionOrchestrator);
            this.executeStepProcessor           = new ExecuteStepProcessor(_stepRegistry, executionOrchestrator, tableFormatter);
            this.scenarioDataStoreInitProcessor = new ScenarioDataStoreInitProcessor(this._assemblyLoader);
            this.specDataStoreInitProcessor     = new SpecDataStoreInitProcessor(this._assemblyLoader);
            this.suiteDataStoreInitProcessor    = new SuiteDataStoreInitProcessor(this._assemblyLoader);
        }
        public void ShouldClearExistingGaugeMessages()
        {
            var mockExectionHelper = new Mock <IExecutionOrchestrator>();

            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ScenarioExecutionStarting,
                StepExecutionStartingRequest = new StepExecutionStartingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec     = new SpecInfo(),
                        CurrentScenario = new ScenarioInfo()
                    }
                }
            };

            var protoExecutionResult = new ProtoExecutionResult {
                ExecutionTime = 0, Failed = false
            };

            mockExectionHelper.Setup(executor =>
                                     executor.ExecuteHooks(It.IsAny <string>(), It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                           It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            var hookRegistry = new Mock <IHookRegistry>();

            hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet <IHookMethod>());

            var pendingMessages = new List <string> {
                "one", "two"
            };
            var pendingScreenshots = new List <byte[]> {
                Encoding.ASCII.GetBytes("screenshot")
            };

            mockExectionHelper.Setup(x =>
                                     x.ExecuteHooks("BeforeStep", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                    It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            mockExectionHelper.Setup(x =>
                                     x.GetAllPendingMessages()).Returns(pendingMessages);
            mockExectionHelper.Setup(x =>
                                     x.GetAllPendingScreenshots()).Returns(pendingScreenshots);

            var processor = new StepExecutionStartingProcessor(mockExectionHelper.Object);
            var result    = processor.Process(request);

            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Message, pendingMessages);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Screenshots, pendingScreenshots);
        }
        public void ShouldClearExistingGaugeMessages()
        {
            var mockExectionHelper = new Mock <IExecutionOrchestrator>();

            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ScenarioExecutionStarting,
                StepExecutionStartingRequest = new StepExecutionStartingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec     = new SpecInfo(),
                        CurrentScenario = new ScenarioInfo()
                    }
                }
            };

            var protoExecutionResult = new ProtoExecutionResult {
                ExecutionTime = 0, Failed = false
            };

            mockExectionHelper.Setup(executor =>
                                     executor.ExecuteHooks(It.IsAny <string>(), It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                           It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            var hookRegistry = new Mock <IHookRegistry>();

            hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet <IHookMethod>());
            var mockAssemblyLoader       = new Mock <IAssemblyLoader>();
            var mockMessageCollectorType = new Mock <Type>();
            var mockReflectionWrapper    = new Mock <IReflectionWrapper>();

            mockReflectionWrapper.Setup(x => x.InvokeMethod(mockMessageCollectorType.Object, null, "Clear",
                                                            BindingFlags.Static | BindingFlags.Public))
            .Verifiable();
            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector))
            .Returns(mockMessageCollectorType.Object);

            var processor = new StepExecutionStartingProcessor(mockExectionHelper.Object, mockAssemblyLoader.Object,
                                                               mockReflectionWrapper.Object);

            processor.Process(request);

            mockReflectionWrapper.VerifyAll();
        }
Пример #5
0
        public void ShouldPasssExecutionContextToHook()
        {
            var sandbox = SandboxBuilder.Build();
            var stepExecutionStartingProcessor = new StepExecutionStartingProcessor(new MethodExecutor(sandbox));

            var message = new Message
            {
                MessageId   = 1234,
                MessageType = Message.Types.MessageType.StepExecutionStarting,
                StepExecutionStartingRequest = new StepExecutionStartingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec = new SpecInfo {
                            Name = "Foo Spec"
                        },
                        CurrentScenario = new ScenarioInfo {
                            Name = "Foo Scenario"
                        },
                        CurrentStep = new StepInfo
                        {
                            Step = new ExecuteStepRequest
                            {
                                ParsedStepText = "Foo Step",
                                ActualStepText = "Foo Step"
                            }
                        }
                    }
                }
            };
            var result = stepExecutionStartingProcessor.Process(message);

            AssertRunnerDomainDidNotLoadUsersAssembly();
            var protoExecutionResult = result.ExecutionStatusResponse.ExecutionResult;

            Assert.IsNotNull(protoExecutionResult);
            Assert.IsFalse(protoExecutionResult.Failed);
        }
        public void ShouldProcessBeforeStepHooks()
        {
            var methodExecutor = new Mock <IMethodExecutor>();

            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.StepExecutionStarting,
                StepExecutionStartingRequest = new StepExecutionStartingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec     = new SpecInfo(),
                        CurrentScenario = new ScenarioInfo()
                    }
                }
            };

            var protoExecutionResult = new ProtoExecutionResult {
                ExecutionTime = 0, Failed = false, Message = { "one", "two" }
            };

            methodExecutor.Setup(executor =>
                                 executor.ExecuteHooks("BeforeStep", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(), It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            var hookRegistry = new Mock <IHookRegistry>();

            hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet <IHookMethod>());

            var result = new StepExecutionStartingProcessor(methodExecutor.Object).Process(request);

            Assert.False(result.ExecutionStatusResponse.ExecutionResult.Failed);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Message, new List <string>()
            {
                "one", "two"
            });
        }
Пример #7
0
        public void ShouldClearExistingGaugeMessages()
        {
            var mockExectionHelper = new Mock <IExecutionOrchestrator>();

            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ScenarioExecutionStarting,
                StepExecutionStartingRequest = new StepExecutionStartingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec     = new SpecInfo(),
                        CurrentScenario = new ScenarioInfo()
                    }
                }
            };

            var protoExecutionResult = new ProtoExecutionResult {
                ExecutionTime = 0, Failed = false
            };

            mockExectionHelper.Setup(executor =>
                                     executor.ExecuteHooks(It.IsAny <string>(), It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                           It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            var hookRegistry = new Mock <IHookRegistry>();

            hookRegistry.Setup(registry => registry.BeforeStepHooks).Returns(new HashSet <IHookMethod>());
            var mockAssemblyLoader       = new Mock <IAssemblyLoader>();
            var mockMessageCollectorType = new Mock <Type>();

            var mockReflectionWrapper = new Mock <IReflectionWrapper>();
            var pendingMessages       = new List <string>()
            {
                "one", "two"
            };
            var pendindScreenshots = new List <byte[]>()
            {
                Encoding.ASCII.GetBytes("screenshot")
            };

            mockReflectionWrapper.Setup(x => x.InvokeMethod(mockMessageCollectorType.Object, null,
                                                            "GetAllPendingMessages",
                                                            BindingFlags.Static | BindingFlags.Public))
            .Returns(pendingMessages).Verifiable();
            mockReflectionWrapper.Setup(x => x.InvokeMethod(mockMessageCollectorType.Object, null,
                                                            "GetAllPendingScreenshots",
                                                            BindingFlags.Static | BindingFlags.Public))
            .Returns(pendindScreenshots).Verifiable();
            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector))
            .Returns(mockMessageCollectorType.Object);
            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.ScreenshotCollector))
            .Returns(mockMessageCollectorType.Object);

            var processor = new StepExecutionStartingProcessor(mockExectionHelper.Object, mockAssemblyLoader.Object,
                                                               mockReflectionWrapper.Object);
            var result = processor.Process(request);

            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Message, pendingMessages);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.ScreenShot.ToList(), pendindScreenshots);


            mockReflectionWrapper.VerifyAll();
        }