Exemple #1
0
        public static void InitializeRandom(this CremaAttribute attribute)
        {
            attribute.DataType = CremaDataTypeUtility.GetBaseTypes().Random();

            if (RandomUtility.Within(25) == true)
            {
                attribute.Comment = RandomUtility.NextString();
            }

            if (RandomUtility.Within(25) == true)
            {
                attribute.DefaultValue = RandomUtility.Next(attribute.DataType);
            }

            if (RandomUtility.Within(25) == true && CremaDataTypeUtility.CanUseAutoIncrement(attribute.DataType) == true && attribute.DefaultValue == DBNull.Value)
            {
                attribute.AutoIncrement = RandomUtility.NextBoolean();
            }
        }
Exemple #2
0
        public static CremaDataTable CreateNormalTable(CremaDataSet dataSet, string tableName, string categoryPath)
        {
            var table  = dataSet.Tables.Add(tableName, categoryPath);
            var column = table.Columns.Add("ID", typeof(int));

            column.IsKey         = true;
            column.AutoIncrement = true;
            foreach (var item in CremaDataTypeUtility.GetBaseTypes())
            {
                table.Columns.Add($"column_{item.GetTypeName()}", item);
            }
            foreach (var item in dataSet.Types)
            {
                table.Columns.Add($"column_{item.Name}", item);
            }
            CreateNormalChild(table, "child_table");
            FillTable(table);
            return(table);
        }
        public void SetDataTypeToCremaTypeColumn()
        {
            var column = this.RandomOrDefault(item => item.CremaType != null);

            if (column == null)
            {
                return;
            }

            if (column.DefaultValue is DBNull == false)
            {
                column.DefaultValue = DBNull.Value;
            }

            var cremaType = column.CremaType;
            var refCount  = cremaType.ReferencedColumns.Length;
            var dataType  = CremaDataTypeUtility.GetBaseTypes().Random();

            column.DataType = dataType;
            Assert.AreEqual(dataType, column.DataType);
            Assert.IsNull(column.CremaType);
            Assert.AreNotEqual(refCount, cremaType.ReferencedColumns.Length);
        }
Exemple #4
0
 public void SetAutoIncrementTrue()
 {
     this.attribute.DataType      = CremaDataTypeUtility.GetBaseTypes().Random(item => CremaDataTypeUtility.CanUseAutoIncrement(item));
     this.attribute.AutoIncrement = true;
     Assert.AreEqual(true, this.attribute.AutoIncrement);
 }
 public void SetAutoIncrementTrueToDefaultValueColumn_Fail()
 {
     this.column.DataType      = CremaDataTypeUtility.GetBaseTypes().Random(item => CremaDataTypeUtility.CanUseAutoIncrement(item));
     this.column.DefaultValue  = RandomUtility.Next(this.column.DataType);
     this.column.AutoIncrement = true;
 }