private void DoTableBatchBasicOperationsCheck(TablePayloadFormat format) { tableClient.DefaultRequestOptions.PayloadFormat = format; string pk = Guid.NewGuid().ToString(); TableBatchOperation batch = new TableBatchOperation(); // Add insert DynamicTableEntity ent1 = GenerateRandomEntity(pk); TableOperation operation1 = TableOperation.Insert(ent1); batch.Add(operation1); DynamicTableEntity ent2 = GenerateRandomEntity(pk); TableOperation operation2 = TableOperation.Insert(ent2); batch.Add(operation2); TableOperation[] operationsArray = new TableOperation[2]; batch.CopyTo(operationsArray, 0); Assert.AreEqual(operation1.Entity.RowKey, operationsArray[0].Entity.RowKey); Assert.AreEqual(operation1.OperationType, operationsArray[0].OperationType); Assert.AreEqual(operation2.Entity.RowKey, operationsArray[1].Entity.RowKey); Assert.AreEqual(operation2.OperationType, operationsArray[1].OperationType); Assert.AreEqual(0, batch.IndexOf(operation1)); Assert.AreEqual(1, batch.IndexOf(operation2)); IEnumerator<TableOperation> enumerator = batch.GetEnumerator(); int totalCount = 0; while (enumerator.MoveNext()) totalCount++; Assert.AreEqual(2, totalCount); Assert.IsTrue(batch.Remove(operation2)); Assert.IsFalse(batch.IsReadOnly); TestHelper.ExpectedException<NotSupportedException>(() => batch[0] = operation1, "Setter is not supported for TableBatchOperation"); }