public static void GetString(params object[] values) { var array = new SqlArray(values.Select(NewExpression).ToArray()); var s = array.ToString(); Assert.NotEmpty(s); }
public static void TryInvalidOperations(int length) { var array = new SqlArray(new SqlExpression[length]); Assert.Throws <NotSupportedException>(() => ((IList)array).Add(null)); Assert.Throws <NotSupportedException>(() => ((IList)array).Remove(null)); Assert.Throws <NotSupportedException>(() => ((IList)array).Clear()); Assert.Throws <NotSupportedException>(() => ((IList)array).Insert(0, null)); }
public static void CopyTo(params object[] values) { var array = new SqlArray(values.Select(NewExpression).ToArray()); var expressions = new SqlExpression[values.Length]; array.CopyTo(expressions, 0); Assert.Equal(array.Length, expressions.Length); }
public static void ConstructArray(int length) { var type = new SqlArrayType(length); var array = new SqlArray(new SqlExpression[length]); Assert.Equal(length, array.Length); Assert.True(type.IsInstanceOf(array)); }
public static void MakeAsString(int length, string expected) { var exps = new SqlExpression[length]; for (int i = 0; i < length; i++) { exps[i] = SqlExpression.Constant(new SqlObject(PrimitiveTypes.Integer(), (SqlNumber)i)); } var array = new SqlArray(exps); var s = array.ToString(); Assert.Equal(expected, s); }
public static void EnumerateItems(params object[] values) { var array = new SqlArray(values.Select(NewExpression).ToArray()); Assert.Equal(values.Length, array.Length); Assert.True(array.Length > 0); var expected = SqlObject.New(SqlValueUtil.FromObject(values[0])); var first = array.First(); Assert.IsType <SqlConstantExpression>(first); var itemValue = ((SqlConstantExpression)first).Value; Assert.Equal(expected, itemValue); }
public static void Create(params object[] values) { var array = new SqlArray(values.Select(NewExpression).ToArray()); Assert.Equal(values.Length, array.Length); Assert.True(array.Length > 0); var expected = SqlObject.New(SqlValueUtil.FromObject(values[0])); var item = array[0]; Assert.IsType <SqlConstantExpression>(item); var itemValue = ((SqlConstantExpression)item).Value; Assert.Equal(expected, itemValue); }
public static void CopyToOtherArray(int length1, int length2) { var exps = new SqlExpression[length1]; for (int i = 0; i < length1; i++) { exps[i] = SqlExpression.Constant(new SqlObject(PrimitiveTypes.Integer(), (SqlNumber)i)); } var array1 = new SqlArray(exps); var array2 = new SqlArray(new SqlExpression[length2]); array1.CopyTo(array2, 0); Assert.NotNull(array2[length1 - 1]); Assert.Equal(array1[length1 - 1], array2[length1 - 1]); }
public static void AccessItem(int length, int offset) { var exps = new SqlExpression[length]; for (int i = 0; i < length; i++) { exps[i] = SqlExpression.Constant(new SqlObject(PrimitiveTypes.Integer(), (SqlNumber)i)); } var array = new SqlArray(exps); Assert.Equal(length, exps.Length); Assert.NotNull(array[offset]); Assert.IsType <SqlConstantExpression>(array[offset]); Assert.IsType <SqlNumber>(((SqlConstantExpression)array[offset]).Value.Value); Assert.Equal(offset, (int)(SqlNumber)((SqlConstantExpression)array[offset]).Value.Value); }
public static void Enumerate(int length) { var exps = new SqlExpression[length]; for (int i = 0; i < length; i++) { exps[i] = SqlExpression.Constant(new SqlObject(PrimitiveTypes.Integer(), (SqlNumber)i)); } var array = new SqlArray(exps); var last = array.Last(); Assert.NotNull(last); Assert.IsType <SqlConstantExpression>(last); Assert.Equal(length - 1, (int)(SqlNumber)((SqlConstantExpression)last).Value.Value); }
public static void CopyToExpressionsArray(int length, int expLength) { var exps = new SqlExpression[length]; for (int i = 0; i < length; i++) { exps[i] = SqlExpression.Constant(new SqlObject(PrimitiveTypes.Integer(), (SqlNumber)i)); } var array = new SqlArray(exps); var expArray = new SqlExpression[expLength]; array.CopyTo(expArray, 0); Assert.NotNull(expArray[length - 1]); Assert.Equal(array[length - 1], expArray[length - 1]); }
public static void InvalidListOperations() { var array = new SqlArray(new SqlExpression[0]); var list = array as IList; Assert.True(list.IsFixedSize); Assert.False(list.IsSynchronized); Assert.True(list.IsReadOnly); Assert.Equal(array.Length, list.Count); var dummy = SqlExpression.Constant(SqlObject.Bit(false)); Assert.Throws <NotSupportedException>(() => list.Add(dummy)); Assert.Throws <NotSupportedException>(() => list.Contains(dummy)); Assert.Throws <NotSupportedException>(() => list.IndexOf(dummy)); Assert.Throws <NotSupportedException>(() => list[0] = dummy); Assert.Throws <NotSupportedException>(() => list.Clear()); Assert.Throws <NotSupportedException>(() => list.Remove(dummy)); Assert.Throws <NotSupportedException>(() => list.RemoveAt(0)); Assert.Throws <NotSupportedException>(() => list.Insert(2, dummy)); }
public static SqlObject Array(SqlArray array) { return(new SqlObject(PrimitiveTypes.Array(array.Length), array)); }
public ArrayEnumerator(SqlArray array) { this.array = array; Reset(); }