Exemplo n.º 1
0
        public void Dispose_ShouldDisconnect()
        {
            // Arrange
            var          connection = new SapConnection(_interopMock.Object, new SapConnectionParameters());
            RfcErrorInfo errorInfo;

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

            connection.Connect();

            // Act
            connection.Dispose();

            // Assert
            _interopMock.Verify(x => x.CloseConnection(RfcConnectionHandle, out errorInfo), Times.Once);
        }
Exemplo n.º 2
0
        public void Dispose_DisconnectionFailed_ShouldNotThrow()
        {
            // Arrange
            var          connection = new SapConnection(_interopMock.Object, new SapConnectionParameters());
            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(RfcResultCode.RFC_CANCELED);

            connection.Connect();

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

            // Assert
            action.Should().NotThrow();
        }