Example #1
0
        public async Task Invoke_NoInput_NoOutput_ShouldInvokeFunctionAsync()
        {
            RfcErrorInfo errorInfo;
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);
            var          result   = await function.InvokeAsync();

            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
Example #2
0
        public void Invoke_NoInput_NoOutput_ShouldInvokeFunction()
        {
            RfcErrorInfo errorInfo;
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);

            function.Invoke();

            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
Example #3
0
        public async Task Invoke_WithInput_NoOutput_ShouldMapInputAsync()
        {
            RfcErrorInfo errorInfo;
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);

            var result = await function.InvokeAsync(new { Value = 123 });

            _interopMock.Verify(x => x.SetInt(FunctionHandle, "VALUE", 123, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
Example #4
0
        public void Dispose_ShouldDestroyFunction()
        {
            RfcErrorInfo errorInfo;
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);

            _interopMock.Setup(x => x.DestroyFunction(It.IsAny <IntPtr>(), out errorInfo)).Returns(RfcResultCodes.RFC_OK);

            function.Dispose();

            _interopMock.Verify(x => x.DestroyFunction(FunctionHandle, out errorInfo), Times.Once);
        }
Example #5
0
        public void CreateFunction_CreationFailed_ShouldThrowException()
        {
            var errorInfo = new RfcErrorInfo {
                Code = RfcResultCodes.RFC_NOT_FOUND
            };

            _interopMock.Setup(x => x.CreateFunction(It.IsAny <IntPtr>(), out errorInfo));

            var    rfcFunction = new RfcFunction(_interopMock.Object);
            Action action      = () => rfcFunction.CreateFunction(ConnectionMock.Object, "FunctonA");

            action.Should().Throw <RfcException>().WithMessage("SAP RFC Error: RFC_NOT_FOUND");
        }
Example #6
0
        public void Dispose_ShouldDestroyFunction()
        {
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetFunctionDesc(It.IsAny <IntPtr>(), It.IsAny <string>(), out errorInfo)).Returns(FunctionDescriptionHandle);
            _interopMock.Setup(x => x.CreateFunction(It.IsAny <IntPtr>(), out errorInfo)).Returns(FunctionHandle);
            var          rfcFunction = new RfcFunction(_interopMock.Object);
            IRfcFunction function    = rfcFunction.CreateFunction(ConnectionMock.Object, "FunctonA");

            function.Dispose();

            _interopMock.Verify(x => x.DestroyFunction(FunctionHandle, out errorInfo), Times.Once);
        }
Example #7
0
        public async Task Invoke_WithInput_WithOutput_ShouldMapInputAndOutputAsync()
        {
            int          value = 456;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetInt(It.IsAny <IntPtr>(), It.IsAny <string>(), out value, out errorInfo));
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);

            OutputModel result = await function.InvokeAsync <OutputModel>(new { Value = 123 });

            _interopMock.Verify(x => x.SetInt(FunctionHandle, "VALUE", 123, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.GetInt(FunctionHandle, "VALUE", out value, out errorInfo), Times.Once);
        }
Example #8
0
        public void Invoke_WithInput_NoOutput_ShouldMapInput()
        {
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetFunctionDesc(It.IsAny <IntPtr>(), It.IsAny <string>(), out errorInfo)).Returns(FunctionDescriptionHandle);
            _interopMock.Setup(x => x.CreateFunction(It.IsAny <IntPtr>(), out errorInfo)).Returns(FunctionHandle);
            var          rfcFunction = new RfcFunction(_interopMock.Object);
            IRfcFunction function    = rfcFunction.CreateFunction(ConnectionMock.Object, "FunctonA");

            function.Invoke(new { Value = 123 });

            _interopMock.Verify(x => x.SetInt(FunctionHandle, "VALUE", 123, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
Example #9
0
        public async Task Invoke_NoInput_WithOutput_ShouldMapOutputAsync()
        {
            int          value = 456;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetInt(FunctionHandle, "VALUE", out value, out errorInfo));
            IRfcFunction function = new RfcFunction(_interopMock.Object, RfcConnectionHandle, FunctionHandle);

            OutputModel result = await function.InvokeAsync <OutputModel>();

            result.Should().NotBeNull();
            result.Value.Should().Be(value);
            _interopMock.Verify(x => x.GetInt(FunctionHandle, "VALUE", out value, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }
Example #10
0
        public void Invoke_NoInput_WithOutput_ShouldMapOutput()
        {
            int          value = 456;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetFunctionDesc(It.IsAny <IntPtr>(), It.IsAny <string>(), out errorInfo)).Returns(FunctionDescriptionHandle);
            _interopMock.Setup(x => x.CreateFunction(It.IsAny <IntPtr>(), out errorInfo)).Returns(FunctionHandle);
            _interopMock.Setup(x => x.GetInt(FunctionHandle, "VALUE", out value, out errorInfo));
            var          rfcFunction = new RfcFunction(_interopMock.Object);
            IRfcFunction function    = rfcFunction.CreateFunction(ConnectionMock.Object, "FunctonA");

            OutputModel result = function.Invoke <OutputModel>();

            result.Should().NotBeNull();
            result.Value.Should().Be(value);
            _interopMock.Verify(x => x.GetInt(FunctionHandle, "VALUE", out value, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.Invoke(RfcConnectionHandle, FunctionHandle, out errorInfo), Times.Once);
        }