sdk/dotnet/test/Microsoft.Datasync.Client.Test/Offline/SyncContext.Test.cs
/// <summary>
/// Creates some random operations in the queue and returns the number of operations created.
/// </summary>
/// <param name="tableName">The name of the table holding the operations.</param>
/// <param name="itemCount">The number of items to create.</param>
/// <returns>The list of items created.</returns>
Creates some random operations in the queue and returns the number of operations created.
Creates some random operations in the queue and returns the number of operations created .
private List<TableOperation> AddRandomOperations(string tableName, int itemCount = 0)
        {
            if (itemCount <= 0)
            {
                itemCount = rnd.Next(1, 20);
            }
            List<TableOperation> operations = new();
            for (var i = 0; i < itemCount; i++)
            {
                int t = rnd.Next(1, 4);
                switch (t)
                {
                    case 1:
                        operations.Add(new DeleteOperation(tableName, Guid.NewGuid().ToString()) { Item = jsonObject });
                        break;
                    case 2:
                        operations.Add(new InsertOperation(tableName, Guid.NewGuid().ToString()));
                        break;
                    default:
                        operations.Add(new UpdateOperation(tableName, Guid.NewGuid().ToString()));
                        break;
                }
            }
            store.Upsert(SystemTables.OperationsQueue, operations.Select(op => op.Serialize()));
            return operations;
        }
private List < TableOperation > AddRandomOperations ( string tableName , int itemCount = 0 ) { if ( itemCount <= 0 ) { itemCount = rnd . Next ( 1 , 20 ) ; } List < TableOperation > operations = new ( ) ; for ( var i = 0 ; i < itemCount ; i ++ ) { int t = rnd . Next ( 1 , 4 ) ; switch ( t ) { case 1 : operations . Add ( new DeleteOperation ( tableName , Guid . NewGuid ( ) . ToString ( ) ) { Item = jsonObject } ) ; break ; case 2 : operations . Add ( new InsertOperation ( tableName , Guid . NewGuid ( ) . ToString ( ) ) ) ; break ; default : operations . Add ( new UpdateOperation ( tableName , Guid . NewGuid ( ) . ToString ( ) ) ) ; break ; } } store . Upsert ( SystemTables . OperationsQueue , operations . Select ( op => op . Serialize ( ) ) ) ; return operations ; }
Creates some random operations in the queue and returns the number of operations created.
Creates some random operations in the queue and returns the number of operations created .
The list of items created.
The list of items created .
tableName
string
The name of the table holding the operations.
The name of the table holding the operations .
itemCount
int
The number of items to create.
The number of items to create .