public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType)
        {
            const string parsedStepText = "Foo";
            var          protoTable     = new  ProtoTable();
            var          headers        = new ProtoTableRow();

            headers.Cells.AddRange(new List <string> {
                "foo", "bar"
            });
            protoTable.Headers = headers;
            var row = new ProtoTableRow();

            row.Cells.AddRange(new List <string> {
                "foorow1", "foorow2"
            });
            protoTable.Rows.AddRange(new List <ProtoTableRow>()
            {
                row
            });

            var request = new Message()
            {
                MessageType        = Message.Types.MessageType.ExecuteStep,
                ExecuteStepRequest = new ExecuteStepRequest()
                {
                    ActualStepText = parsedStepText,
                    ParsedStepText = parsedStepText,
                    Parameters     =
                    {
                        new Parameter()
                        {
                            ParameterType = parameterType,
                            Table         = protoTable
                        }
                    },
                },
                MessageId = 20
            };

            var mockStepRegistry = new Mock <IStepRegistry>();

            mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true);
            var fooMethodInfo = new GaugeMethod {
                Name = "Foo", ParameterCount = 1
            };

            mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo);
            var mockMethodExecutor = new Mock <IMethodExecutor>();

            mockMethodExecutor.Setup(e => e.Execute(fooMethodInfo, It.IsAny <string[]>())).Returns(() => new ProtoExecutionResult()
            {
                ExecutionTime = 1,
                Failed        = false
            });

            var response = new ExecuteStepProcessor(mockStepRegistry.Object, mockMethodExecutor.Object).Process(request);

            mockMethodExecutor.Verify(executor => executor.Execute(fooMethodInfo, It.Is <string[]>(strings => HasTable(strings))));
            Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed);
        }
        public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.ParameterType parameterType)
        {
            const string parsedStepText = "Foo";
            var          protoTable     = new ProtoTable();
            var          tableJSON      = "{'headers':['foo', 'bar'],'rows':[['foorow1','barrow1']]}";
            var          request        = new Message
            {
                MessageType        = Message.Types.MessageType.ExecuteStep,
                ExecuteStepRequest = new ExecuteStepRequest
                {
                    ActualStepText = parsedStepText,
                    ParsedStepText = parsedStepText,
                    Parameters     =
                    {
                        new Parameter
                        {
                            ParameterType = parameterType,
                            Table         = protoTable
                        }
                    }
                },
                MessageId = 20
            };

            var mockStepRegistry = new Mock <IStepRegistry>();

            mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true);
            var fooMethodInfo = new GaugeMethod {
                Name = "Foo", ParameterCount = 1
            };

            mockStepRegistry.Setup(x => x.MethodFor(parsedStepText)).Returns(fooMethodInfo);
            var mockOrchestrator = new Mock <IExecutionOrchestrator>();

            mockOrchestrator.Setup(e => e.ExecuteStep(fooMethodInfo, It.IsAny <string[]>())).Returns(() =>
                                                                                                     new ProtoExecutionResult
            {
                ExecutionTime = 1,
                Failed        = false
            });

            var mockAssemblyLoader = new Mock <IAssemblyLoader>();

            mockAssemblyLoader.Setup(x => x.GetLibType(LibType.MessageCollector));
            var mockTableFormatter = new Mock <ITableFormatter>();

            mockTableFormatter.Setup(x => x.GetJSON(protoTable))
            .Returns(tableJSON);
            var response =
                new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object)
                .Process(request);

            mockOrchestrator.Verify(executor =>
                                    executor.ExecuteStep(fooMethodInfo, It.Is <string[]>(strings => strings[0] == tableJSON)));
            Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed);
        }