示例#1
0
        public void Dispose_ShouldDisconnect()
        {
            var          connection = new RfcConnection(_interopMock.Object, new RfcConnectionOption());
            RfcErrorInfo errorInfo;

            _interopMock
            .Setup(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), It.IsAny <uint>(), out errorInfo))
            .Returns(RfcConnectionHandle);

            connection.Connect();

            connection.Dispose();

            _interopMock.Verify(x => x.CloseConnection(RfcConnectionHandle, out errorInfo), Times.Once);
        }
示例#2
0
        public void Dispose_ShouldDisconnectFunction()
        {
            RfcErrorInfo errorInfo;
            var          connection = new RfcConnection(_interopMock.Object, RfcConfigurationOption);

            _interopMock
            .Setup(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), It.IsAny <uint>(), out errorInfo))
            .Returns(RfcConnectionHandle);
            _interopMock.Setup(x => x.CloseConnection(It.IsAny <IntPtr>(), out errorInfo)).Returns(RfcResultCodes.RFC_OK);
            connection.Connect();

            connection.Dispose();

            _interopMock.Verify(x => x.CloseConnection(RfcConnectionHandle, out errorInfo), Times.Once);
        }
示例#3
0
        public void Dispose_DisconnectionFailed_ShouldNotThrow()
        {
            var          connection = new RfcConnection(_interopMock.Object, new RfcConnectionOption());
            RfcErrorInfo errorInfo;

            _interopMock
            .Setup(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), It.IsAny <uint>(), out errorInfo))
            .Returns(RfcConnectionHandle);
            _interopMock
            .Setup(x => x.CloseConnection(It.IsAny <IntPtr>(), out errorInfo))
            .Returns(RfcResultCodes.RFC_CANCELED);

            connection.Connect();

            Action action = () => connection.Dispose();

            action.Should().NotThrow();
        }