コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void ShouldExecutreBeforeScenarioHook()
        {
            var mockAssemblyLoader = new Mock <IAssemblyLoader>();
            var mockType           = new Mock <Type>().Object;

            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector)).Returns(mockType);
            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.ScreenshotCollector)).Returns(mockType);
            var scenarioExecutionStartingRequest = new ScenarioExecutionStartingRequest
            {
                CurrentExecutionInfo = new ExecutionInfo
                {
                    CurrentSpec     = new SpecInfo(),
                    CurrentScenario = new ScenarioInfo()
                }
            };
            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.SpecExecutionStarting,
                ScenarioExecutionStartingRequest = scenarioExecutionStartingRequest
            };

            var mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            var protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };
            IEnumerable <string> pendingMessages = new List <string> {
                "one", "two"
            };

            mockMethodExecutor.Setup(x =>
                                     x.ExecuteHooks("BeforeScenario", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                    It.IsAny <ExecutionContext>()))
            .Returns(protoExecutionResult);
            var mockReflectionWrapper = new Mock <IReflectionWrapper>();

            mockReflectionWrapper.Setup(x =>
                                        x.InvokeMethod(mockType, null, "GetAllPendingMessages", It.IsAny <BindingFlags>()))
            .Returns(pendingMessages);
            var pendingScreenshot = new List <byte[]> {
                Encoding.ASCII.GetBytes("Screenshot")
            };

            mockReflectionWrapper.Setup(x =>
                                        x.InvokeMethod(mockType, null, "GetAllPendingScreenshots", It.IsAny <BindingFlags>()))
            .Returns(pendingScreenshot);

            var processor = new ScenarioExecutionStartingProcessor(mockMethodExecutor.Object,
                                                                   mockAssemblyLoader.Object, mockReflectionWrapper.Object);

            var result = processor.Process(request);

            Assert.False(result.ExecutionStatusResponse.ExecutionResult.Failed);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Message.ToList(), pendingMessages);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.ScreenShot.ToList(), pendingScreenshot);
        }
コード例 #4
0
        public void ShouldExecutreBeforeScenarioHook()
        {
            var scenarioExecutionEndingRequest = new ScenarioExecutionStartingRequest
            {
                CurrentExecutionInfo = new ExecutionInfo
                {
                    CurrentSpec     = new SpecInfo(),
                    CurrentScenario = new ScenarioInfo()
                }
            };
            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.SpecExecutionStarting,
                ScenarioExecutionStartingRequest = scenarioExecutionEndingRequest
            };

            var mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            var protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };

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

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

            var processor = new ScenarioExecutionStartingProcessor(mockMethodExecutor.Object);

            var result = processor.Process(request);

            Assert.False(result.ExecutionStatusResponse.ExecutionResult.Failed);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Message.ToList(), pendingMessages);
            Assert.AreEqual(result.ExecutionStatusResponse.ExecutionResult.Screenshots.ToList(), pendingScreenshots);
        }
コード例 #5
0
        public void ShouldExecuteBeforeScenarioHook()
        {
            var scenarioExecutionEndingRequest = new ScenarioExecutionStartingRequest
            {
                CurrentExecutionInfo = new ExecutionInfo
                {
                    CurrentSpec     = new SpecInfo(),
                    CurrentScenario = new ScenarioInfo()
                }
            };

            var mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            var protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };

            var pendingMessages = new List <string> {
                "one", "two"
            };
            var pendingScreenshotFiles = new List <string> {
                "screenshot.png"
            };

            mockMethodExecutor.Setup(x =>
                                     x.ExecuteHooks("BeforeScenario", It.IsAny <HooksStrategy>(), It.IsAny <IList <string> >(),
                                                    It.IsAny <ExecutionInfo>()))
            .Returns(protoExecutionResult);
            mockMethodExecutor.Setup(x =>
                                     x.GetAllPendingMessages()).Returns(pendingMessages);
            mockMethodExecutor.Setup(x =>
                                     x.GetAllPendingScreenshotFiles()).Returns(pendingScreenshotFiles);

            var processor = new ScenarioExecutionStartingProcessor(mockMethodExecutor.Object);

            var result = processor.Process(scenarioExecutionEndingRequest);

            Assert.False(result.ExecutionResult.Failed);
            Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages);
            Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles);
        }