public void Extract_TableWithLessRowsThanAnnounced_ShouldReturnExtractedRows()
        {
            // Arrange
            var          tableHandle = (IntPtr)3334;
            var          rowHandle   = (IntPtr)4445;
            uint         rowCount    = 3;
            int          intValue    = 888;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetTable(It.IsAny <IntPtr>(), It.IsAny <string>(), out tableHandle, out errorInfo));
            _interopMock.Setup(x => x.GetRowCount(It.IsAny <IntPtr>(), out rowCount, out errorInfo));
            _interopMock.Setup(x => x.MoveToFirstRow(It.IsAny <IntPtr>(), out errorInfo));
            _interopMock.Setup(x => x.GetCurrentRow(It.IsAny <IntPtr>(), out errorInfo)).Returns(rowHandle);
            _interopMock.Setup(x => x.GetInt(It.IsAny <IntPtr>(), It.IsAny <string>(), out intValue, out errorInfo));

            _interopMock
            .Setup(x => x.MoveToNextRow(It.IsAny <IntPtr>(), out errorInfo))
            .Returns(RfcResultCode.RFC_TABLE_MOVE_EOF);

            // Act
            ArrayModel result = OutputMapper.Extract <ArrayModel>(_interopMock.Object, DataHandle);

            // Assert
            result.Should().NotBeNull();
            result.Elements.Should().HaveCount(1);
        }
Exemple #2
0
        public void Extract_TableWithRows_ShouldMapToArrayOfElements()
        {
            // Arrange
            var          tableHandle = (IntPtr)3334;
            var          rowHandle   = (IntPtr)4445;
            uint         rowCount    = 3;
            int          intValue    = 888;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetTable(It.IsAny <IntPtr>(), It.IsAny <string>(), out tableHandle, out errorInfo));
            _interopMock.Setup(x => x.GetRowCount(It.IsAny <IntPtr>(), out rowCount, out errorInfo));
            _interopMock.Setup(x => x.GetCurrentRow(It.IsAny <IntPtr>(), out errorInfo)).Returns(rowHandle);
            _interopMock.Setup(x => x.GetInt(It.IsAny <IntPtr>(), It.IsAny <string>(), out intValue, out errorInfo));

            // Act
            ArrayModel result = OutputMapper.Extract <ArrayModel>(_interopMock.Object, DataHandle);

            // Assert
            _interopMock.Verify(
                x => x.GetTable(DataHandle, "ELEMENTS", out tableHandle, out errorInfo),
                Times.Once);
            _interopMock.Verify(
                x => x.GetRowCount(tableHandle, out rowCount, out errorInfo),
                Times.Once);
            _interopMock.Verify(
                x => x.GetCurrentRow(tableHandle, out errorInfo),
                Times.Exactly(3));
            _interopMock.Verify(
                x => x.GetInt(rowHandle, "VALUE", out intValue, out errorInfo),
                Times.Exactly(3));
            _interopMock.Verify(x => x.MoveToNextRow(tableHandle, out errorInfo), Times.Exactly(3));
            result.Should().NotBeNull();
            result.Elements.Should().HaveCount(3);
            result.Elements.First().Value.Should().Be(888);
        }
        public void Extract_TableWithZeroRows_ShouldNotCallMoveToFirstRow()
        {
            // Arrange
            var          tableHandle = (IntPtr)3334;
            var          rowHandle   = (IntPtr)4445;
            uint         rowCount    = 0;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetTable(It.IsAny <IntPtr>(), It.IsAny <string>(), out tableHandle, out errorInfo));
            _interopMock.Setup(x => x.GetRowCount(It.IsAny <IntPtr>(), out rowCount, out errorInfo));
            _interopMock.Setup(x => x.MoveToFirstRow(It.IsAny <IntPtr>(), out errorInfo));
            _interopMock.Setup(x => x.GetCurrentRow(It.IsAny <IntPtr>(), out errorInfo)).Returns(rowHandle);

            _interopMock
            .Setup(x => x.MoveToNextRow(It.IsAny <IntPtr>(), out errorInfo))
            .Returns(RfcResultCode.RFC_TABLE_MOVE_EOF);

            // Act
            ArrayModel result = OutputMapper.Extract <ArrayModel>(_interopMock.Object, DataHandle);

            // Assert
            _interopMock.Verify(
                x => x.GetTable(DataHandle, "ELEMENTS", out tableHandle, out errorInfo),
                Times.Once);
            _interopMock.Verify(
                x => x.GetRowCount(tableHandle, out rowCount, out errorInfo),
                Times.Once);
            _interopMock.Verify(
                x => x.MoveToFirstRow(tableHandle, out errorInfo),
                Times.Never);
            _interopMock.Verify(
                x => x.GetCurrentRow(tableHandle, out errorInfo),
                Times.Never);
            _interopMock.Verify(x => x.MoveToNextRow(tableHandle, out errorInfo), Times.Never);
            result.Should().NotBeNull();
            result.Elements.Should().HaveCount(0);
        }