public void Ping_NotConnected_ShouldReturnFalse() { var connection = new RfcConnection(_interopMock.Object, new RfcConnectionOption()); var pingResult = connection.Ping(); pingResult.Should().BeFalse(); }
public void Ping_Connected_PingTimeout_ShouldReturnFalse() { RfcErrorInfo errorInfo; _interopMock .Setup(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), It.IsAny <uint>(), out errorInfo)) .Returns(RfcConnectionHandle); _interopMock .Setup(x => x.Ping(RfcConnectionHandle, out errorInfo)) .Returns(RfcResultCodes.RFC_TIMEOUT); var connection = new RfcConnection(_interopMock.Object, new RfcConnectionOption()); connection.Connect(); var pingResult = connection.Ping(); pingResult.Should().BeFalse(); }
public void Ping_Connected_SuccessfulPing_ShouldReturnTrue() { RfcErrorInfo errorInfo; _interopMock .Setup(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), It.IsAny <uint>(), out errorInfo)) .Returns(RfcConnectionHandle); _interopMock .Setup(x => x.Ping(RfcConnectionHandle, out errorInfo)) .Returns(RfcResultCodes.RFC_OK); var connection = new RfcConnection(_interopMock.Object, RfcConfigurationOption); connection.Connect(); var pingResult = connection.Ping(); pingResult.Should().BeTrue(); }
static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed(o => { var version = RfcConnection.GetLibVersion(); Console.WriteLine($"currently loaded sapnwrfc library version : Major {version.MajorVersion}, Minor {version.MinorVersion}, patchLevel {version.PatchLevel}"); /** * Use the connection builder fluent api. */ using (var conn = new RfcConnection(builder => builder .UseConnectionHost(o.Hostname) .UseLogonUserName(o.UserName) .UseLogonPassword(o.Password) .UseLogonClient(o.Client))) { conn.Open(); conn.Ping(); // do something more interesting here... } /** * Use the connection string api. */ using (var conn = new RfcConnection(connectionString: $"Server={o.Hostname}; Uid={o.UserName}; Passwd={o.Password}; Client={o.Client}")) { conn.Open(); conn.Ping(); // do something more interesting here... } /** * Use the connection uri api. */ using (var conn = new RfcConnection(connectionUri: new Uri($"sap://user={ Uri.EscapeDataString(o.UserName) };passwd={ Uri.EscapeDataString(o.Password) };client={o.Client}@A/{o.Hostname}"))) { conn.Open(); conn.Ping(); // do something more interesting here... } }); }