Exemplo n.º 1
0
            private LogicalPosition _logicalPosition;       // Logical positioning of self

            // NOTE: enumerators in _position always point to valid attributes, to make code for Current be simple.
            //  This means _logicalPosition is required to distinguish times when the overall enumerator should appear
            //  to be positioned either before or after the elements.

            public SteSimplePermEnumerator(SteSimplePermutationGenerator parent, IEnumerable <SteAttributeKey> keysOfInterest)
            {
                _parent = parent;

                // prune keys to ones that are available
                _keysOfInterest = new List <SteAttributeKey>();
                foreach (SteAttributeKey key in keysOfInterest)
                {
                    ArrayList list;
                    if (_parent.AttributeLists.TryGetValue(key, out list) && list.Count > 0)
                    {
                        _keysOfInterest.Add(key);
                    }
                }
                _position = new IEnumerator[_keysOfInterest.Count];
                Reset();
            }
Exemplo n.º 2
0
        static SteSimpleTypeBoundaries()
        {
            List <SteSimpleTypeBoundaries> list = new List <SteSimpleTypeBoundaries>();

            // DevNote: Don't put null value attributes first -- it confuses DataTable generation for SteStructuredTypeBoundaries

            // BigInt
            SteSimplePermutationGenerator type = new SteSimplePermutationGenerator();

            type.Add(SteAttributeKey.SqlDbType, SqlDbType.BigInt);
            type.Add(SteAttributeKey.Value, (Int64)0);
            type.Add(SteAttributeKey.Value, Int64.MaxValue);
            type.Add(SteAttributeKey.Value, Int64.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt64(Int64.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt64(Int64.MinValue));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Binary types
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Binary);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.VarBinary);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Image);
            type.Add(SteAttributeKey.MaxLength, 1);    // a small value
            type.Add(SteAttributeKey.MaxLength, 40);   // Somewhere in the middle
            type.Add(SteAttributeKey.MaxLength, 8000); // Couple values around maximum tds length
            type.Add(SteAttributeKey.Value, CreateByteArray(0));
            type.Add(SteAttributeKey.Value, CreateByteArray(1));
            type.Add(SteAttributeKey.Value, CreateByteArray(50));
            type.Add(SteAttributeKey.Value, s_moderateSizeByteArray);
            type.Add(SteAttributeKey.Value, new SqlBytes(CreateByteArray(0)));
            type.Add(SteAttributeKey.Value, new SqlBytes(CreateByteArray(1)));
            type.Add(SteAttributeKey.Value, new SqlBytes(CreateByteArray(40)));
            type.Add(SteAttributeKey.Value, new SqlBytes(s_moderateSizeByteArray));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            type.Add(SteAttributeKey.Offset, s_doNotUseMarker);
            type.Add(SteAttributeKey.Offset, -1);
            type.Add(SteAttributeKey.Offset, 0);
            type.Add(SteAttributeKey.Offset, 10);
            type.Add(SteAttributeKey.Offset, 8000);
            type.Add(SteAttributeKey.Offset, Int32.MaxValue);
            type.Add(SteAttributeKey.Length, 0);
            type.Add(SteAttributeKey.Length, 40);
            type.Add(SteAttributeKey.Length, 8000);
            type.Add(SteAttributeKey.Length, 1000000);
            type.Add(SteAttributeKey.Length, -1);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Byte
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.TinyInt);
            type.Add(SteAttributeKey.Value, Byte.MaxValue);
            type.Add(SteAttributeKey.Value, Byte.MinValue);
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Character (ANSI)
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Char);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Text);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.VarChar);
            type.Add(SteAttributeKey.MaxLength, 1);
            type.Add(SteAttributeKey.MaxLength, 30);
            type.Add(SteAttributeKey.MaxLength, 8000);
            type.Add(SteAttributeKey.Value, CreateString(1));
            type.Add(SteAttributeKey.Value, CreateString(20));
            type.Add(SteAttributeKey.Value, s_moderateSizeString);
            type.Add(SteAttributeKey.Value, CreateString(1).ToCharArray());
            type.Add(SteAttributeKey.Value, CreateString(25).ToCharArray());
            type.Add(SteAttributeKey.Value, s_moderateSizeCharArray);
            type.Add(SteAttributeKey.Value, new SqlChars(CreateString(1).ToCharArray()));
            type.Add(SteAttributeKey.Value, new SqlChars(CreateString(30).ToCharArray()));
            type.Add(SteAttributeKey.Value, new SqlChars(s_moderateSizeCharArray));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Character (UNICODE)
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.NChar);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.NText);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.NVarChar);
            type.Add(SteAttributeKey.MaxLength, 1);
            type.Add(SteAttributeKey.MaxLength, 35);
            type.Add(SteAttributeKey.MaxLength, 4000);
            type.Add(SteAttributeKey.Value, CreateString(1));
            type.Add(SteAttributeKey.Value, CreateString(15));
            type.Add(SteAttributeKey.Value, s_moderateSizeString);
            type.Add(SteAttributeKey.Value, CreateString(1).ToCharArray());
            type.Add(SteAttributeKey.Value, CreateString(20).ToCharArray());
            type.Add(SteAttributeKey.Value, s_moderateSizeCharArray);
            type.Add(SteAttributeKey.Value, new SqlChars(CreateString(1).ToCharArray()));
            type.Add(SteAttributeKey.Value, new SqlChars(CreateString(25).ToCharArray()));
            type.Add(SteAttributeKey.Value, new SqlChars(s_moderateSizeCharArray));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // DateTime
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.DateTime);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.SmallDateTime);
            type.Add(SteAttributeKey.Value, new DateTime(1753, 1, 1));
            type.Add(SteAttributeKey.Value, new SqlDateTime(new DateTime(1753, 1, 1)));  // min SqlDateTime
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Decimal
            //  the TVP test isn't robust in the face of OverflowExceptions on input, so a number of these
            //  values are commented out and other numbers substituted.
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Decimal);
            type.Add(SteAttributeKey.Precision, (byte)38);
            type.Add(SteAttributeKey.Scale, (byte)0);
            type.Add(SteAttributeKey.Scale, (byte)10);
            type.Add(SteAttributeKey.Value, (Decimal)0);
            type.Add(SteAttributeKey.Value, Decimal.MaxValue / 10000000000);
            type.Add(SteAttributeKey.Value, new SqlDecimal(0));
            type.Add(SteAttributeKey.Value, ((SqlDecimal)1234567890123456.789012345678M) * 100); // Bigger than a Decimal
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Float
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Float);
            type.Add(SteAttributeKey.Value, (Double)0);
            type.Add(SteAttributeKey.Value, Double.MaxValue);
            type.Add(SteAttributeKey.Value, Double.MinValue);
            type.Add(SteAttributeKey.Value, new SqlDouble(Double.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlDouble(Double.MinValue));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Int
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Int);
            type.Add(SteAttributeKey.Value, (Int32)0);
            type.Add(SteAttributeKey.Value, Int32.MaxValue);
            type.Add(SteAttributeKey.Value, Int32.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt32(Int32.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt32(Int32.MinValue));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Money types
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Money);
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.SmallMoney);
            type.Add(SteAttributeKey.Value, (Decimal)0);
            type.Add(SteAttributeKey.Value, (Decimal) unchecked (((long)0x8000000000000000L) / 10000));
            type.Add(SteAttributeKey.Value, (Decimal)0x7FFFFFFFFFFFFFFFL / 10000);
            type.Add(SteAttributeKey.Value, new Decimal(-214748.3648)); // smallmoney min
            type.Add(SteAttributeKey.Value, new Decimal(214748.3647));  // smallmoney max
            type.Add(SteAttributeKey.Value, new SqlMoney(((Decimal)Int32.MaxValue) / 10000));
            type.Add(SteAttributeKey.Value, new SqlMoney(((Decimal)Int32.MinValue) / 10000));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // Real
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.Real);
            type.Add(SteAttributeKey.Value, (Single)0);
            type.Add(SteAttributeKey.Value, Single.MaxValue);
            type.Add(SteAttributeKey.Value, Single.MinValue);
            type.Add(SteAttributeKey.Value, new SqlSingle(Single.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlSingle(Single.MinValue));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // SmallInt
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.SmallInt);
            type.Add(SteAttributeKey.Value, (Int16)0);
            type.Add(SteAttributeKey.Value, Int16.MaxValue);
            type.Add(SteAttributeKey.Value, Int16.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt16(Int16.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt16(Int16.MinValue));
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // UniqueIdentifier
            type = new SteSimplePermutationGenerator();
            type.Add(SteAttributeKey.SqlDbType, SqlDbType.UniqueIdentifier);
            type.Add(SteAttributeKey.Value, new Guid());
            type.Add(SteAttributeKey.Value, null);
            type.Add(SteAttributeKey.Value, DBNull.Value);
            list.Add(new SteSimpleTypeBoundaries(type));

            // UDT
            // UDTs aren's supported in all table scenarios, so make a separate list
            // that doesn't include them.
            s_allTypesExceptUdts = new List <SteSimpleTypeBoundaries>(list).AsReadOnly();

            //type = new SteSimplePermutationGenerator();
            //type.Add(SteAttributeKey.SqlDbType, SqlDbType.Udt);
            //type.Add(SteAttributeKey.TypeName, "dbo.WeakAddress");
            //type.Add(SteAttributeKey.Type, typeof(WeakAddress));
            //type.Add(SteAttributeKey.Value, new WeakAddress("", ""));
            //type.Add(SteAttributeKey.Value, new WeakAddress(CreateString(22), ""));
            //type.Add(SteAttributeKey.Value, new WeakAddress(ModerateSizeString, ""));
            //type.Add(SteAttributeKey.Value, null);
            //type.Add(SteAttributeKey.Value, DBNull.Value);
            //
            //SteSimpleTypeBoundaries udt = new SteSimpleTypeBoundaries(type);
            //list.Add(udt);
            //
            //AllTypes = list.AsReadOnly();
            //
            //list = new List<SteSimpleTypeBoundaries>();
            //list.Add(udt);
            //UdtsOnly = list.AsReadOnly();
        }
Exemplo n.º 3
0
 public SteSimpleTypeBoundaries(SteSimplePermutationGenerator generator)
 {
     _generator = generator;
 }