public void ShouldReportArgumentMismatch()
        {
            const string parsedStepText = "Foo";
            var          request        = Message.CreateBuilder()
                                          .SetMessageType(Message.Types.MessageType.ExecuteStep)
                                          .SetExecuteStepRequest(
                ExecuteStepRequest.CreateBuilder()
                .SetActualStepText(parsedStepText)
                .SetParsedStepText(parsedStepText)
                .Build())
                                          .SetMessageId(20)
                                          .Build();
            var mockStepRegistry = new Mock <IStepRegistry>();

            mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true);
            var fooMethodInfo = GetType().GetMethod("Foo");

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

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

            Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed);
            Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage,
                            "Argument length mismatch for Foo. Actual Count: 0, Expected Count: 1");
        }
        public void ShouldProcessExecuteStepRequest()
        {
            const string parsedStepText = "Foo";
            var          request        = Message.CreateBuilder()
                                          .SetMessageType(Message.Types.MessageType.ExecuteStep)
                                          .SetExecuteStepRequest(
                ExecuteStepRequest.CreateBuilder()
                .SetActualStepText(parsedStepText)
                .SetParsedStepText(parsedStepText)
                .AddParameters(
                    Parameter.CreateBuilder()
                    .SetParameterType(Parameter.Types.ParameterType.Static)
                    .SetName("Foo")
                    .SetValue("Bar")
                    .Build())
                .Build())
                                          .SetMessageId(20)
                                          .Build();
            var mockStepRegistry = new Mock <IStepRegistry>();

            mockStepRegistry.Setup(x => x.ContainsStep(parsedStepText)).Returns(true);
            var fooMethodInfo = GetType().GetMethod("Foo");

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

            mockMethodExecutor.Setup(e => e.Execute(fooMethodInfo, It.IsAny <Object[]>())).Returns(() => ProtoExecutionResult.CreateBuilder().SetExecutionTime(1).SetFailed(false).Build());
            var mockSandbox = new Mock <ISandbox>();

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

            Assert.False(response.ExecutionStatusResponse.ExecutionResult.Failed);
        }
Beispiel #3
0
        public void ShouldReportMissingStep()
        {
            const string parsedStepText = "Foo";
            var          request        = Message.CreateBuilder()
                                          .SetMessageType(Message.Types.MessageType.ExecuteStep)
                                          .SetExecuteStepRequest(
                ExecuteStepRequest.CreateBuilder()
                .SetActualStepText(parsedStepText)
                .SetParsedStepText(parsedStepText)
                .Build())
                                          .SetMessageId(20)
                                          .Build();
            var mockStepRegistry = new Mock <IStepRegistry>();

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

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

            Assert.True(response.ExecutionStatusResponse.ExecutionResult.Failed);
            Assert.AreEqual(response.ExecutionStatusResponse.ExecutionResult.ErrorMessage,
                            "Step Implementation not found");
        }