Example #1
0
        public void ShouldExecutreBeforeSpecHook()
        {
            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 request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.SpecExecutionEnding,
                SpecExecutionEndingRequest = new SpecExecutionEndingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec = new SpecInfo()
                    }
                }
            };

            var mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            var protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };
            IEnumerable <string> pendingMessages = new List <string> {
                "one", "two"
            };
            IEnumerable <byte[]> pendingScreenShot = new List <byte[]> {
                Encoding.ASCII.GetBytes("screenshot")
            };

            mockMethodExecutor.Setup(x =>
                                     x.ExecuteHooks("AfterSpec", 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);
            mockReflectionWrapper.Setup(x =>
                                        x.InvokeMethod(mockType, null, "GetAllPendingScreenshots", It.IsAny <BindingFlags>()))
            .Returns(pendingScreenShot);
            var processor = new SpecExecutionEndingProcessor(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);
        }
Example #2
0
        public void ShouldExecutreBeforeSpecHook()
        {
            var request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.SpecExecutionEnding,
                SpecExecutionEndingRequest = new SpecExecutionEndingRequest
                {
                    CurrentExecutionInfo = new ExecutionInfo
                    {
                        CurrentSpec = new SpecInfo()
                    }
                }
            };

            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("AfterSpec", 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 SpecExecutionEndingProcessor(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);
        }
Example #3
0
        public void ShouldExecuteBeforeSpecHook()
        {
            var request = new SpecExecutionEndingRequest
            {
                CurrentExecutionInfo = new ExecutionInfo
                {
                    CurrentSpec = new SpecInfo()
                }
            };

            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("AfterSpec", 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 SpecExecutionEndingProcessor(mockMethodExecutor.Object);

            var result = processor.Process(request);

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