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)
                {
                    if (_parent.AttributeLists.TryGetValue(key, out ArrayList list) && list.Count > 0)
                    {
                        _keysOfInterest.Add(key);
                    }
                }
                _position = new IEnumerator[_keysOfInterest.Count];
                Reset();
            }
예제 #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, (long)0);
            type.Add(SteAttributeKey.Value, long.MaxValue);
            type.Add(SteAttributeKey.Value, long.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt64(long.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt64(long.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, int.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, (int)0);
            type.Add(SteAttributeKey.Value, int.MaxValue);
            type.Add(SteAttributeKey.Value, int.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt32(int.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt32(int.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)int.MaxValue) / 10000));
            type.Add(SteAttributeKey.Value, new SqlMoney(((decimal)int.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, (float)0);
            type.Add(SteAttributeKey.Value, float.MaxValue);
            type.Add(SteAttributeKey.Value, float.MinValue);
            type.Add(SteAttributeKey.Value, new SqlSingle(float.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlSingle(float.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, (short)0);
            type.Add(SteAttributeKey.Value, short.MaxValue);
            type.Add(SteAttributeKey.Value, short.MinValue);
            type.Add(SteAttributeKey.Value, new SqlInt16(short.MaxValue));
            type.Add(SteAttributeKey.Value, new SqlInt16(short.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();
        }
예제 #3
0
 public SteSimpleTypeBoundaries(SteSimplePermutationGenerator generator)
 {
     _generator = generator;
 }