public static void CreateRow(this ITableContent content, Authentication authentication) { var table = content.Table; var parent = content.Parent; string relationID = null; if (parent != null && parent.Any() == true) { relationID = parent.Random().RelationID; } var row = content.AddNew(authentication, relationID); var types = table.GetService(typeof(ITypeCollection)) as ITypeCollection; foreach (var item in table.TableInfo.Columns) { if (item.AutoIncrement == false) { //row.SetField(authentication, item.Name, TypeContextExtensions.GetRandomValue(types, item)); } } if (RandomUtility.Within(25) == true) { row.SetTags(authentication, tags.Random()); } if (RandomUtility.Within(25) == true) { row.SetIsEnabled(authentication, RandomUtility.NextBoolean()); } content.EndNew(authentication, row); }
public static async Task AddRandomRowsAsync(this ITableContent content, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { await AddRandomRowAsync(content, authentication); } }
public static void AddRandomRows(this ITableContent content, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { AddRandomRow(content, authentication); } }
public static bool GenerateRow(this ITableContent content, Authentication authentication) { var row = NewRandomRow(content, authentication); if (FillFields(row, authentication) == true) { if (RandomUtility.Within(25) == true) { row.SetTags(authentication, tags.Random()); } if (RandomUtility.Within(25) == true) { row.SetIsEnabled(authentication, RandomUtility.NextBoolean()); } try { content.EndNew(authentication, row); return(true); } catch { return(false); } } return(false); }
public static void ChangeRow(this ITableContent content, Authentication authentication) { var table = content.Table; var row = content.RandomOrDefault(); if (row == null) { return; } var types = table.GetService(typeof(ITypeCollection)) as ITypeCollection; if (RandomUtility.Within(5) == true) { row.SetTags(authentication, tags.Random()); } else if (RandomUtility.Within(5) == true) { row.SetIsEnabled(authentication, RandomUtility.NextBoolean()); } else { var columnInfo = table.TableInfo.Columns.Random(); //row.SetField(authentication, columnInfo.Name, TypeContextExtensions.GetRandomValue(types, columnInfo)); } }
public static async Task <bool> GenerateRowAsync(this ITableContent content, Authentication authentication) { var row = await NewRandomRowAsync(content, authentication); if (FillFields(row, authentication) == true) { if (RandomUtility.Within(25) == true) { await row.SetTagsAsync(authentication, tags.Random()); } if (RandomUtility.Within(25) == true) { await row.SetIsEnabledAsync(authentication, RandomUtility.NextBoolean()); } try { await content.EndNewAsync(authentication, row); return(true); } catch { return(false); } } return(false); }
public static void EditRandom(this ITableContent content, Authentication authentication, int tryCount) { var failedCount = 0; for (var i = 0; i < tryCount; i++) { try { if (RandomUtility.Within(10) == true || content.Count < 5) { CreateRow(content, authentication); } else if (RandomUtility.Within(75) == true) { ChangeRow(content, authentication); } else if (RandomUtility.Within(10) == true) { DeleteRow(content, authentication); } } catch { failedCount++; } if (failedCount > 5) { break; } } }
public static ITableRow AddRandomRow(this ITableContent content, Authentication authentication) { var row = content.AddNew(authentication, null); row.InitializeRandom(authentication); content.EndNew(authentication, row); return(row); }
public static async Task <ITableRow> AddRandomRowAsync(this ITableContent content, Authentication authentication) { var row = await content.AddNewAsync(authentication, null); await row.InitializeRandomAsync(authentication); await content.EndNewAsync(authentication, row); return(row); }
public static void DeleteRow(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); if (row == null) { return; } row.Delete(authentication); }
private static bool Contains(ITableContent content, string columnName, object value) { foreach (var item in content) { if (object.Equals(item[columnName], value) == true) { return(true); } } return(false); }
public static async Task DeleteRowAsync(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); if (row == null) { return; } await row.DeleteAsync(authentication); }
private async Task<ITableRow> AddNewRowAsync(Authentication authentication, ITableContent content) { var table = content.Table; var parent = table.Parent; if (parent != null) { if (parent.Content.Any() == false) return null; var relationID = parent.Content.Random().ID; return await content.AddNewAsync(authentication, relationID); } return await content.AddNewAsync(authentication, null); }
public static ITableRow NewRandomRow(this ITableContent content, Authentication authentication) { if (content.Parent != null) { var parentRow = content.Parent.Random(); if (parentRow == null) { return(null); } return(content.AddNew(authentication, parentRow.RelationID)); } return(content.AddNew(authentication, null)); }
private ITableRow AddNewRow(Authentication authentication, ITableContent content) { var parent = content.Parent; if (parent != null) { if (parent.Any() == false) { return(null); } var relationID = parent.Random().RelationID; return(content.AddNew(authentication, relationID)); } return(content.AddNew(authentication, null)); }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITableContent_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.Initialize(authentication); content = dataBase.TableContext.Tables.Random(item => item.Parent == null).Content; }); }
public static async Task <ITableRow> NewRandomRowAsync(this ITableContent content, Authentication authentication) { var table = content.Table; var parentContent = table.Parent?.Content; if (parentContent != null) { var parentRow = parentContent.Random(); if (parentRow == null) { return(null); } return(await content.AddNewAsync(authentication, parentRow.ID)); } return(await content.AddNewAsync(authentication, null)); }
//public TableContentDescriptor(Authentication authentication, ITableContent table) // : this(authentication, table, DescriptorTypes.All) //{ //} //public TableContentDescriptor(Authentication authentication, ITableContent content, DescriptorTypes descriptorTypes) // : this(authentication, content, descriptorTypes, null) //{ //} public TableContentDescriptor(Authentication authentication, ITableContent content, DescriptorTypes descriptorTypes, object owner) : base(authentication, content, descriptorTypes) { this.content = content; this.owner = owner ?? this; this.content.Dispatcher.VerifyAccess(); this.domain = this.content.Domain; if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true) { this.content.EditBegun += Content_EditBegun; this.content.EditEnded += Content_EditEnded; this.content.EditCanceled += Content_EditCanceled; this.content.Changed += Content_Changed; this.content.Table.TableInfoChanged += Table_TableInfoChanged; } }
public static async Task GenerateRowsAsync(this ITableContent content, Authentication authentication, int tryCount) { int failedCount = 0; for (var i = 0; i < tryCount; i++) { if (await GenerateRowAsync(content, authentication) == true) { continue; } failedCount++; if (failedCount > 5) { break; } } }
public static void GenerateRows(this ITableContent content, Authentication authentication, int tryCount) { int failedCount = 0; for (var i = 0; i < tryCount; i++) { if (GenerateRow(content, authentication) == true) { continue; } failedCount++; if (failedCount > 5) { break; } } }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITableRow_Deleted_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.Initialize(authentication); content = dataBase.TableContext.Tables.Random(item => item.Parent == null).Content; content.BeginEdit(authentication); content.EnterEdit(authentication); if (content.Count == 0) { content.AddRandomRows(authentication); } row = content.Random(); dataBase.Leave(authentication); dataBase.Unload(authentication); }); }
public static Task AddRandomRowsAsync(this ITableContent content, Authentication authentication) { return(AddRandomRowsAsync(content, authentication, RandomUtility.Next(MinRowCount, MaxRowCount))); }
public static async Task ModifyRandomRowAsync(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); await row?.SetRandomValueAsync(authentication); }
public static async Task RemoveRandomRowAsync(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); await row?.DeleteAsync(authentication); }
public static void RemoveRandomRow(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); row?.Delete(authentication); }
public static void ModifyRandomRow(this ITableContent content, Authentication authentication) { var row = content.RandomOrDefault(); row?.SetRandomValue(authentication); }
public static void AddRandomRows(this ITableContent content, Authentication authentication) { AddRandomRows(content, authentication, RandomUtility.Next(MinRowCount, MaxRowCount)); }
public static Task EditRandomAsync(this ITableContent content, Authentication authentication) { return(EditRandomAsync(content, authentication, 1)); }
//private IDomain domain; public TableContentListItemBase(Authentication authentication, ITableContent content, object owner) : base(authentication, new TableContentDescriptor(authentication, content, DescriptorTypes.IsSubscriptable, owner), owner) { }
public static void EditRandom(this ITableContent content, Authentication authentication) { EditRandom(content, authentication, 1); }