public void ToInterop_NoValueSet_ShouldReturnEmptyArray()
        {
            var option = new RfcConnectionOption();

            RfcConnectionParameter[] interopParameters = option.ToInterop();

            interopParameters.Should().BeEmpty();
        }
        public void Parse_ShouldSetProperties()
        {
            const string CONNECTION_STRING = "AppServerHost=MyFancyHost;User= SomeUsername; Password = SomePassword ";

            var parameters = new RfcConnectionOption().Parse(CONNECTION_STRING);

            parameters.Should().NotBeNull();
            parameters.AppServerHost.Should().Be("MyFancyHost");
            parameters.User.Should().Be("SomeUsername");
            parameters.Password.Should().Be("SomePassword");
        }
        public void ToInterop_ShouldUseNameFromAttribute()
        {
            var option = new RfcConnectionOption
            {
                RepositoryPassword = "******"
            };

            RfcConnectionParameter[] interopParameters = option.ToInterop();

            interopParameters.First().Name.Should().Be("REPOSITORY_PASSWD");
        }
Example #4
0
        public void Connect_ConnectionSucceeds_ShouldOpenConnection()
        {
            var parameters = new RfcConnectionOption {
                AppServerHost = "my-server.com"
            };
            var connection = new RfcConnection(_interopMock.Object, parameters);

            connection.Connect();

            RfcErrorInfo errorInfo;

            _interopMock.Verify(x => x.OpenConnection(It.IsAny <RfcConnectionParameter[]>(), 1, out errorInfo), Times.Once);
        }
        public void ToInterop_ShouldMapNonNullValues()
        {
            var option = new RfcConnectionOption
            {
                Name     = "Test",
                Language = "TR",
            };

            RfcConnectionParameter[] interopParameters = option.ToInterop();

            interopParameters.Should().HaveCount(2);
            interopParameters.First().Should().BeEquivalentTo(new { Name = "NAME", Value = "Test" });
            interopParameters.Last().Should().BeEquivalentTo(new { Name = "LANG", Value = "TR" });
        }
Example #6
0
        private uint GetRfcConnectionOptionPropertyCount(RfcConnectionOption connectionOptions)
        {
            PropertyInfo[] properties = connectionOptions.GetType().GetProperties();
            uint           counter    = 0;

            foreach (PropertyInfo propertyInfo in properties)
            {
                object value = propertyInfo.GetValue(connectionOptions, null);
                if (value != null)
                {
                    counter++;
                }
            }

            return(counter);
        }
        public void Parse_AllProperties()
        {
            RfcConnectionOption expectedParameters = Fixture.Create <RfcConnectionOption>();
            string connectionString = typeof(RfcConnectionOption)
                                      .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                                      .Aggregate(new StringBuilder(), (sb, propertyInfo) =>
            {
                object value = propertyInfo.GetValue(expectedParameters);
                sb.Append($"{propertyInfo.Name}={value};");
                return(sb);
            })
                                      .ToString();

            var parameters = new RfcConnectionOption().Parse(connectionString);

            parameters.Should().BeEquivalentTo(expectedParameters);
        }
Example #8
0
 protected RfcConnectionBase(IRfcInterop interop, RfcConnectionOption options)
 {
     _interop = interop;
     _options = options;
 }