public void Setup()
        {
            var mockHookRegistry = new Mock <IHookRegistry>();

            var hooks = new HashSet <IHookMethod>
            {
                new HookMethod("BeforeSpec", GetType().GetMethod("Foo"), typeof(Step).Assembly)
            };

            mockHookRegistry.Setup(x => x.BeforeSuiteHooks).Returns(hooks);
            var executionEndingRequest = new ExecutionStartingRequest();

            _request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ExecutionEnding,
                ExecutionStartingRequest = executionEndingRequest
            };

            _mockMethodExecutor   = new Mock <IMethodExecutor>();
            _protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };
            _mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSuite", It.IsAny <HooksStrategy>(), new List <string>(), It.IsAny <ExecutionContext>()))
            .Returns(_protoExecutionResult);
            _executionStartingProcessor = new ExecutionStartingProcessor(_mockMethodExecutor.Object);
        }
        public void ShouldProcessHooks()
        {
            var executionStartingRequest = new ExecutionStartingRequest();
            var result = _executionStartingProcessor.Process(executionStartingRequest);

            _mockMethodExecutor.VerifyAll();
            Assert.AreEqual(result.ExecutionResult.Message, _pendingMessages);
            Assert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles);
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            var mockHookRegistry   = new Mock <IHookRegistry>();
            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 mockMethod = new MockMethodBuilder(mockAssemblyLoader)
                             .WithName("Foo")
                             .WithFilteredHook(LibType.BeforeSpec)
                             .Build();

            var hooks = new HashSet <IHookMethod>
            {
                new HookMethod(LibType.BeforeSpec, mockMethod, mockAssemblyLoader.Object)
            };

            mockHookRegistry.Setup(x => x.BeforeSuiteHooks).Returns(hooks);
            var executionEndingRequest = new ExecutionStartingRequest();

            _request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ExecutionEnding,
                ExecutionStartingRequest = executionEndingRequest
            };

            _mockMethodExecutor   = new Mock <IExecutionOrchestrator>();
            _protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };
            _mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSuite", It.IsAny <HooksStrategy>(), new List <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(_pendingScrennshots);
            _executionStartingProcessor = new ExecutionStartingProcessor(_mockMethodExecutor.Object,
                                                                         mockAssemblyLoader.Object, mockReflectionWrapper.Object);
        }
Ejemplo n.º 4
0
        public override Task <Empty> NotifyExecutionStarting(ExecutionStartingRequest request, ServerCallContext context)
        {
            try
            {
                TraceLogger.Info($"{nameof(NotifyExecutionStarting)} received");
                TraceLogger.Verbose(System.Text.Json.JsonSerializer.Serialize(request));

                if (request.SuiteResult != null)
                {
                    _sender.StartLaunch(request);
                }
            }
            catch (Exception exp)
            {
                TraceLogger.Error(exp.ToString());
            }

            return(Task.FromResult(new Empty()));
        }
Ejemplo n.º 5
0
        public void StartLaunch(ExecutionStartingRequest request)
        {
            lock (_lockObj)
            {
                if (_launch == null)
                {
                    var suiteExecutionResult = request.SuiteResult;

                    // deffer starting of launch
                    _startLaunchRequest = new StartLaunchRequest
                    {
                        Name        = _configuration.GetValue("Launch:Name", suiteExecutionResult.ProjectName),
                        Description = _configuration.GetValue("Launch:Description", string.Empty),
                        Attributes  = _configuration.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new Client.Abstractions.Models.ItemAttribute {
                            Key = a.Key, Value = a.Value
                        }).ToList(),
                        StartTime = DateTime.UtcNow
                    };
                }

                _launchesCount++;
            }
        }
Ejemplo n.º 6
0
        public void Setup()
        {
            var mockHookRegistry   = new Mock <IHookRegistry>();
            var mockAssemblyLoader = new Mock <IAssemblyLoader>();
            var mockMethod         = new MockMethodBuilder(mockAssemblyLoader)
                                     .WithName("Foo")
                                     .WithFilteredHook(LibType.BeforeSpec)
                                     .Build();

            var hooks = new HashSet <IHookMethod>
            {
                new HookMethod(LibType.BeforeSpec, mockMethod, mockAssemblyLoader.Object)
            };

            mockHookRegistry.Setup(x => x.BeforeSuiteHooks).Returns(hooks);
            var executionEndingRequest = new ExecutionStartingRequest();

            _request = new Message
            {
                MessageId   = 20,
                MessageType = Message.Types.MessageType.ExecutionEnding,
                ExecutionStartingRequest = executionEndingRequest
            };

            _mockMethodExecutor   = new Mock <IMethodExecutor>();
            _protoExecutionResult = new ProtoExecutionResult
            {
                ExecutionTime = 0,
                Failed        = false
            };
            _mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSuite", It.IsAny <HooksStrategy>(), new List <string>()))
            .Returns(_protoExecutionResult);
            var mockReflectionWrapper = new Mock <IReflectionWrapper>();

            _executionStartingProcessor = new ExecutionStartingProcessor(_mockMethodExecutor.Object, mockAssemblyLoader.Object, mockReflectionWrapper.Object);
        }
        public virtual ExecutionStatusResponse Process(ExecutionStartingRequest request)
        {
            var debuggingEnv = Utils.TryReadEnvValue("DEBUGGING");

            if (debuggingEnv != null && debuggingEnv.ToLower().Equals("true"))
            {
                // if the runner is launched in DEBUG mode, let the debugger attach.
                Console.WriteLine("Runner Ready for Debugging at Process ID " +
                                  System.Diagnostics.Process.GetCurrentProcess().Id);
                var j = 0;
                while (!Debugger.IsAttached)
                {
                    j++;
                    //Trying to debug, wait for a debugger to attach
                    Thread.Sleep(100);
                    //Timeout, no debugger connected, break out into a normal execution.
                    if (j == 300)
                    {
                        break;
                    }
                }
            }
            return(ExecuteHooks(request.CurrentExecutionInfo));
        }
Ejemplo n.º 8
0
 public override Task <ExecutionStatusResponse> StartExecution(ExecutionStartingRequest request, ServerCallContext context)
 {
     return(_pool.Execute(getStream(request.Stream), () => this.executionStartingProcessor.Process(request)));
 }
Ejemplo n.º 9
0
 public override Task <ExecutionStatusResponse> StartExecution(ExecutionStartingRequest request, ServerCallContext context)
 {
     return(Task.FromResult(this.executionStartingProcessor.Process(request)));
 }
 public override Task <Empty> NotifyExecutionStarting(ExecutionStartingRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new Empty()));
 }