public void RTableCreateTableAlreadyExistsSync() { try { string tableName = this.GenerateRandomTableName(); this.SetupRTableEnv(tableName); Assert.IsTrue(this.repTable.Exists(), "RTable does not exist"); // Try to create the same RTable again. ReplicatedTable curTable = new ReplicatedTable(this.repTable.TableName, this.configurationService); Assert.IsFalse(curTable.CreateIfNotExists(), "Calling CreateIfNotExists() again returned true. Should be false."); int replicasCreated = curTable.replicasCreated; Assert.AreEqual(replicasCreated, 0, "Calling CreateIfNotExists() again returned replicasCreated={0} > 0. Should be 0.", replicasCreated); } finally { base.DeleteAllRtableResources(); } }
public void TableQueryableCreateQueryNoPartitionKey() { Thread.Sleep(10000); string tableName = this.GenerateRandomTableName(); ReplicatedTable localRTable = new ReplicatedTable(tableName, this.configurationService); localRTable.CreateIfNotExists(); RTableWrapperForSampleRTableEntity localRTableWrapper = RTableWrapperForSampleRTableEntity.GetRTableWrapper(localRTable); CloudTableClient tableClient = localRTable.GetTailTableClient(); CloudTable table = tableClient.GetTableReference(localRTable.TableName); string pk = "0"; try { try { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } try { pk = "1"; TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } IQueryable <BaseEntity> tableQuery = table.CreateQuery <BaseEntity>(); IQueryable <BaseEntity> rtableQuery = localRTable.CreateQuery <BaseEntity>(); var list = tableQuery.AsEnumerable(); int tableCount = 0; int rtableCount = 0; foreach (BaseEntity ent in list) { tableCount++; } foreach (BaseEntity ent in rtableQuery.ToList()) { rtableCount++; Assert.IsTrue(ent.ETag != ent._rtable_Version.ToString(), "ETag is not virtualized when using CreateQuery()"); } Assert.IsTrue(tableCount == rtableCount, "Query counts are different"); Assert.IsTrue(tableCount == 20, "Query counts are different"); // But, with "CreateReplicatedQuery" ETag is virtualized IQueryable <BaseEntity> virtualizedRtableQuery = localRTable.CreateReplicatedQuery <BaseEntity>(); foreach (BaseEntity ent in virtualizedRtableQuery.ToList()) { Assert.IsTrue(ent._rtable_Version == 0); Assert.IsTrue(ent.ETag == ent._rtable_Version.ToString(), "ETag is virtualized when using CreateReplicatedQuery()"); ent.A += "`"; // Update should go fine since ETag is virtualized TableOperation operation = TableOperation.Replace(ent); TableResult result = localRTable.Execute(operation); Assert.IsTrue(result != null && result.HttpStatusCode == (int)HttpStatusCode.NoContent); } virtualizedRtableQuery = localRTable.CreateReplicatedQuery <BaseEntity>(); foreach (BaseEntity ent in virtualizedRtableQuery.ToList()) { Assert.IsTrue(ent._rtable_Version == 1); Assert.IsTrue(ent.ETag == ent._rtable_Version.ToString(), "ETag is virtualized when using CreateReplicatedQuery()"); } } catch (Exception e) { Console.WriteLine("Error during query processing: {0}", e.ToString()); } finally { localRTable.DeleteIfExists(); } }
public bool CreateIfNotExists() { return(rtable.CreateIfNotExists()); }
public void TableQueryableCreateQueryNoPartitionKey() { Thread.Sleep(10000); string tableName = this.GenerateRandomTableName(); ReplicatedTable localRTable = new ReplicatedTable(tableName, this.configurationService); localRTable.CreateIfNotExists(); RTableWrapperForSampleRTableEntity localRTableWrapper = RTableWrapperForSampleRTableEntity.GetRTableWrapper(localRTable); CloudTableClient tableClient = localRTable.GetTailTableClient(); CloudTable table = tableClient.GetTableReference(localRTable.TableName); string pk = "0"; try { try { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } try { pk = "1"; TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } IQueryable<BaseEntity> tableQuery = table.CreateQuery<BaseEntity>(); IQueryable<BaseEntity> rtableQuery = localRTable.CreateQuery<BaseEntity>(); var list = tableQuery.AsEnumerable(); int tableCount = 0; int rtableCount = 0; foreach (BaseEntity ent in list) { tableCount++; } foreach (BaseEntity ent in rtableQuery.ToList()) { rtableCount++; } Assert.IsTrue(tableCount == rtableCount, "Query counts are different"); Assert.IsTrue(tableCount == 20, "Query counts are different"); } catch (Exception e) { Console.WriteLine("Error during query processing: {0}", e.ToString()); } finally { localRTable.DeleteIfExists(); } }
public void TableQueryableCreateQueryNoPartitionKey() { Thread.Sleep(10000); string tableName = this.GenerateRandomTableName(); ReplicatedTable localRTable = new ReplicatedTable(tableName, this.configurationService); localRTable.CreateIfNotExists(); RTableWrapperForSampleRTableEntity localRTableWrapper = RTableWrapperForSampleRTableEntity.GetRTableWrapper(localRTable); CloudTableClient tableClient = localRTable.GetTailTableClient(); CloudTable table = tableClient.GetTableReference(localRTable.TableName); string pk = "0"; try { try { TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } try { pk = "1"; TableBatchOperation batch = new TableBatchOperation(); for (int j = 0; j < 10; j++) { BaseEntity ent = GenerateRandomEntity(pk); ent.RowKey = string.Format("{0:0000}", j); batch.Insert(ent); } localRTable.ExecuteBatch(batch); } catch (Exception ex) { Console.WriteLine("Exception during test case init {0}", ex.ToString()); throw; } IQueryable <BaseEntity> tableQuery = table.CreateQuery <BaseEntity>(); IQueryable <BaseEntity> rtableQuery = localRTable.CreateQuery <BaseEntity>(); var list = tableQuery.AsEnumerable(); int tableCount = 0; int rtableCount = 0; foreach (BaseEntity ent in list) { tableCount++; } foreach (BaseEntity ent in rtableQuery.ToList()) { rtableCount++; } Assert.IsTrue(tableCount == rtableCount, "Query counts are different"); Assert.IsTrue(tableCount == 20, "Query counts are different"); } catch (Exception e) { Console.WriteLine("Error during query processing: {0}", e.ToString()); } finally { localRTable.DeleteIfExists(); } }