public void TestGetDecimal() { var reader = new ListDataReader <Student>(_Students); reader.Read(); var col = "Decimal2"; Assert.Equal(4M, reader.GetDecimal(col)); reader.Read(); reader.Read(); Assert.Equal(5M, reader.GetDecimal(col)); }
public async void TestGetDecimal() { 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(decimal) || p.PropertyType == typeof(decimal?))) { Assert.Equal(p.GetMethod.Invoke(st, new object[0]), reader.GetDecimal(index)); } else if (p.PropertyType.GetTypeInfo().IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>) && p.GetMethod.Invoke(st, new object[0]) == null) { Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetDecimal(index)); } else if (p.PropertyType == typeof(short) || p.PropertyType == typeof(short?) || p.PropertyType == typeof(int) || p.PropertyType == typeof(int?) || p.PropertyType == typeof(byte) || p.PropertyType == typeof(byte?) || p.PropertyType == typeof(long) || p.PropertyType == typeof(long?)) { Assert.NotNull(reader.GetDecimal(index)); } else { Assert.ThrowsAny <RuntimeBinderException>(() => reader.GetDecimal(index)); } index++; } } }