public static async Task CopyTableAsync(this ITableContext tableContext, Authentication authentication) { var category = await tableContext.GetRandomTableItemAsync(item => item is ITableCategory) as ITableCategory; if (await tableContext.GetRandomTableItemAsync(item => item is ITable) is not ITable table) { return; } await table.CopyAsync(authentication, "Table_" + RandomUtility.NextIdentifier(), category.Path, RandomUtility.NextBoolean()); }
public static async Task CreateTableAsync(this ITableContext tableContext, Authentication authentication) { var category = await tableContext.GetRandomTableItemAsync(item => item is ITableCategory) as ITableCategory; var template = await category.AddNewTableAsync(authentication); await GenerateColumnsAsync(template, authentication, RandomUtility.Next(3, 10)); if (RandomUtility.Within(25) == true) { await template.SetCommentAsync(authentication, RandomUtility.NextString()); } await template.EndEditAsync(authentication); var tables = template.Target as ITable[]; var table = tables.First(); while (RandomUtility.Within(10)) { var childTemplate = await table.NewTableAsync(authentication); await GenerateColumnsAsync(childTemplate, authentication, RandomUtility.Next(3, 10)); await childTemplate.EndEditAsync(authentication); } var content = table.Content; await content.EnterEditAsync(authentication); await GenerateRowsAsync(content, authentication, RandomUtility.Next(10, 100)); foreach (var item in table.Childs) { await GenerateRowsAsync(item.Content, authentication, RandomUtility.Next(10, 100)); } await content.LeaveEditAsync(authentication); }