public void TestGetInt32()
        {
            var reader = new ListDataReader <Student>(_Students);

            reader.Read();
            var col = "ClassNumber";

            Assert.Equal(2, reader.GetInt32(col));
            reader.Read();
            reader.Read();
            Assert.Equal(3, reader.GetInt32(col));
        }
示例#2
0
        public async void TestGetInt32()
        {
            var reader = new ListDataReader <Student>(_Students);
            var ps     = _Properties.Where(i => i.CanRead).ToArray();

            foreach (var st in _Students)
            {
                await reader.ReadAsync();

                var index = 0;
                foreach (var p in ps)
                {
                    if (p.GetMethod.Invoke(st, new object[0]) != null &&
                        (p.PropertyType == typeof(int) || p.PropertyType == typeof(int?)))
                    {
                        Assert.Equal(p.GetMethod.Invoke(st, new object[0]), reader.GetInt32(index));
                    }
                    else if (p.PropertyType.GetTypeInfo().IsGenericType &&
                             p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>) &&
                             p.GetMethod.Invoke(st, new object[0]) == null)
                    {
                        Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetInt32(index));
                    }
                    else if (p.PropertyType == typeof(short) || p.PropertyType == typeof(short?) ||
                             p.PropertyType == typeof(byte) || p.PropertyType == typeof(byte?))
                    {
                        Assert.NotNull(reader.GetInt32(index));
                    }
                    else
                    {
                        Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetInt32(index));
                    }
                    index++;
                }
            }
        }