public void GetAttributes_GettingTheAttributesFails_ShouldThrowException() { // Arrange RfcAttributes rfcAttributes = Fixture.Create <RfcAttributes>(); RfcErrorInfo errorInfo; _interopMock .Setup(x => x.GetConnectionAttributes(It.IsAny <IntPtr>(), out rfcAttributes, out errorInfo)) .Returns(RfcResultCode.RFC_CLOSED); var connection = new SapConnection(_interopMock.Object, new SapConnectionParameters()); // Act Action action = () => connection.GetAttributes(); // Assert action.Should().Throw <SapException>() .WithMessage("SAP RFC Error: RFC_CLOSED"); }
public void GetAttributes_GettingConnectionAttributesSucceeds_ShouldReturnConnectionAttributes() { // Arrange RfcAttributes rfcAttributes = Fixture.Create <RfcAttributes>(); rfcAttributes.Reserved = null; RfcErrorInfo errorInfo; _interopMock .Setup(x => x.GetConnectionAttributes(It.IsAny <IntPtr>(), out rfcAttributes, out errorInfo)) .Returns(RfcResultCode.RFC_OK); var connection = new SapConnection(_interopMock.Object, new SapConnectionParameters()); // Act SapAttributes attributes = connection.GetAttributes(); // Assert attributes.Should().NotBeNull(); attributes.Should().BeEquivalentTo(rfcAttributes, config => config .ComparingByMembers <RfcAttributes>() .ComparingByMembers <SapAttributes>() .ExcludingMissingMembers()); }