Ejemplo n.º 1
0
        public static void GetString(params object[] values)
        {
            var array = new SqlArray(values.Select(NewExpression).ToArray());

            var s = array.ToString();

            Assert.NotEmpty(s);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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]);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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]);
        }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
 public static SqlObject Array(SqlArray array)
 {
     return(new SqlObject(PrimitiveTypes.Array(array.Length), array));
 }
Ejemplo n.º 14
0
 public ArrayEnumerator(SqlArray array)
 {
     this.array = array;
     Reset();
 }