Esempio n. 1
0
        public void ThrowOnError_NoError_ShouldNotThrow()
        {
            var errorInfo = new RfcErrorInfo {
                Code = RfcResultCodes.RFC_OK
            };

            Action action = () => errorInfo.ThrowOnError();

            action.Should().NotThrow();
        }
Esempio n. 2
0
        public void ThrowOnError_NoError_ShouldNotCallBeforeThrowAction()
        {
            var errorInfo = new RfcErrorInfo {
                Code = RfcResultCodes.RFC_OK
            };
            var beforeThrowActionMock = new Mock <Action>();

            errorInfo.ThrowOnError(beforeThrowActionMock.Object);

            beforeThrowActionMock.Verify(x => x(), Times.Never);
        }
Esempio n. 3
0
        public void ThrowOnError_Error_ShouldCallBeforeThrowActionAndThrowRfcException()
        {
            var errorInfo = new RfcErrorInfo {
                Code = RfcResultCodes.RFC_CANCELED, Message = "Connection cancelled"
            };
            var beforeThrowActionMock = new Mock <Action>();

            Action action = () => errorInfo.ThrowOnError(beforeThrowActionMock.Object);

            action.Should().Throw <RfcException>().Which.Message.Should().Be("SAP RFC Error: RFC_CANCELED with message: Connection cancelled");
            beforeThrowActionMock.Verify(x => x(), Times.Once);
        }
        public void ThrowOnError_NoError_ShouldNotThrow()
        {
            // Arrange
            var errorInfo = new RfcErrorInfo {
                Code = RfcResultCode.RFC_OK
            };

            // Act
            Action action = () => errorInfo.ThrowOnError();

            // Assert
            action.Should().NotThrow();
        }
        public void ThrowOnError_Error_ShouldCallBeforeThrowActionAndThrowRfcException()
        {
            // Arrange
            var errorInfo = new RfcErrorInfo
            {
                Code    = RfcResultCode.RFC_CLOSED,
                Message = "Connection closed",
            };
            var beforeThrowActionMock = new Mock <Action>();

            // Act
            Action action = () => errorInfo.ThrowOnError(beforeThrowActionMock.Object);

            // Assert
            action.Should().Throw <SapException>()
            .Which.Message.Should().Be("SAP RFC Error: RFC_CLOSED with message: Connection closed");
            beforeThrowActionMock.Verify(x => x(), Times.Once);
        }