internal void ValidateConvertTo <T> (object objectInScope, T expectedValue)
        {
            // Get Operations for associated Engine
            ObjectOperations operations = _testEng.CreateOperations();

            Assert.AreEqual(expectedValue, operations.ConvertTo <T>(objectInScope));
        }
Ejemplo n.º 2
0
        public static object GetMember(this ObjectOperations operations, object instance, string name, Type type)
        {
            var rubyTypedValue = operations.GetMember(instance, name);

            if (type.IsArray)
            {
                var untypedArray = (from item in (IEnumerable <dynamic>) rubyTypedValue
                                    select operations.ConvertTo(item, type.GetElementType())).ToArray();

                var typedArray = Array.CreateInstance(type.GetElementType(), untypedArray.Length);
                for (var i = 0; i < untypedArray.Length; i++)
                {
                    typedArray.SetValue(untypedArray[i], i);
                }

                return(typedArray);
            }

            return(operations.ConvertTo(rubyTypedValue, type));
        }