Пример #1
0
        protected virtual async Task CreateTestStorageEntities()
        {
            TestQueue = QueueClient.GetQueueReference(string.Format("test-input-{0}", FixtureId));
            await TestQueue.CreateIfNotExistsAsync();

            await TestQueue.ClearAsync();

            // This queue name should really be suffixed by -fsharp, -csharp, -node etc.
            MobileTablesQueue = QueueClient.GetQueueReference("mobiletables-input");
            await MobileTablesQueue.CreateIfNotExistsAsync(); // do not clear this queue since it is currently shared between fixtures

            TestInputContainer = BlobClient.GetContainerReference(string.Format("test-input-{0}", FixtureId));
            await TestInputContainer.CreateIfNotExistsAsync();

            // Processing a large number of blobs on startup can take a while,
            // so let's start with an empty container.
            await TestHelpers.ClearContainerAsync(TestInputContainer);

            TestOutputContainer = BlobClient.GetContainerReference(string.Format("test-output-{0}", FixtureId));
            await TestOutputContainer.CreateIfNotExistsAsync();

            await TestHelpers.ClearContainerAsync(TestOutputContainer);

            TestTable = TableClient.GetTableReference("test");
            await TestTable.CreateIfNotExistsAsync();

            await DeleteEntities(TestTable, "AAA");
            await DeleteEntities(TestTable, "BBB");

            var batch = new TableBatchOperation();

            batch.Insert(new TestEntity {
                PartitionKey = "AAA", RowKey = "001", Region = "West", Name = "Test Entity 1", Status = 0
            });
            batch.Insert(new TestEntity {
                PartitionKey = "AAA", RowKey = "002", Region = "East", Name = "Test Entity 2", Status = 1
            });
            batch.Insert(new TestEntity {
                PartitionKey = "AAA", RowKey = "003", Region = "West", Name = "Test Entity 3", Status = 1
            });
            batch.Insert(new TestEntity {
                PartitionKey = "AAA", RowKey = "004", Region = "West", Name = "Test Entity 4", Status = 1
            });
            batch.Insert(new TestEntity {
                PartitionKey = "AAA", RowKey = "005", Region = "East", Name = "Test Entity 5", Status = 0
            });
            await TestTable.ExecuteBatchAsync(batch);

            batch = new TableBatchOperation();
            batch.Insert(new TestEntity {
                PartitionKey = "BBB", RowKey = "001", Region = "South", Name = "Test Entity 1", Status = 0
            });
            batch.Insert(new TestEntity {
                PartitionKey = "BBB", RowKey = "002", Region = "West", Name = "Test Entity 2", Status = 1
            });
            batch.Insert(new TestEntity {
                PartitionKey = "BBB", RowKey = "003", Region = "West", Name = "Test Entity 3", Status = 0
            });
            await TestTable.ExecuteBatchAsync(batch);
        }