Exemplo n.º 1
0
        public static void InitializeRandom(this ITableColumn tableColumn, Authentication authentication)
        {
            var template = tableColumn.Template;
            var table    = tableColumn.Template.Table;

            if (RandomUtility.Within(75) == true)
            {
                tableColumn.SetDataType(authentication, CremaDataTypeUtility.GetBaseTypeNames().Random(item => item != typeof(bool).GetTypeName()));
            }
            else
            {
                tableColumn.SetDataType(authentication, template.SelectableTypes.Random());
            }

            if (template.Count == 0)
            {
                tableColumn.SetIsKey(authentication, true);
            }
            else if (RandomUtility.Within(10) && tableColumn.DataType != typeof(bool).GetTypeName())
            {
                tableColumn.SetIsKey(authentication, true);
                tableColumn.SetIsUnique(authentication, RandomUtility.Within(75));
            }

            if (RandomUtility.Within(25) && tableColumn.DataType != typeof(bool).GetTypeName())
            {
                var unique = RandomUtility.Within(75);
                if (unique != false || template.PrimaryKey.Count() != 1)
                {
                    tableColumn.SetIsUnique(authentication, unique);
                }
            }

            if (RandomUtility.Within(25) == true)
            {
                tableColumn.SetComment(authentication, RandomUtility.NextString());
            }

            if (RandomUtility.Within(25) == true)
            {
                tableColumn.SetDefaultValue(authentication, tableColumn.GetRandomString());
            }

            if (CremaDataTypeUtility.CanUseAutoIncrement(tableColumn.DataType) == true && tableColumn.DefaultValue == null)
            {
                tableColumn.SetAutoIncrement(authentication, RandomUtility.NextBoolean());
            }

            if (RandomUtility.Within(5) == true)
            {
                tableColumn.SetIsReadOnly(authentication, true);
            }
        }
Exemplo n.º 2
0
 public void SetIsKey(ITableColumn column, TaskContext context)
 {
     column.Dispatcher.Invoke(() =>
     {
         var isKey = RandomUtility.NextBoolean();
         column.SetIsKey(context.Authentication, isKey);
     });
 }
Exemplo n.º 3
0
 public void SetIsKey()
 {
     column.SetIsKey(authentication, RandomUtility.NextBoolean());
 }