Ejemplo n.º 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);
        }
        protected virtual void CreateTestStorageEntities()
        {
            TestQueue = QueueClient.GetQueueReference(string.Format("test-input-{0}", _testId));
            TestQueue.CreateIfNotExists();
            TestQueue.Clear();

            TestInputContainer = BlobClient.GetContainerReference(string.Format("test-input-{0}", _testId));
            TestInputContainer.CreateIfNotExists();

            TestOutputContainer = BlobClient.GetContainerReference(string.Format("test-output-{0}", _testId));
            TestOutputContainer.CreateIfNotExists();

            TestTable = TableClient.GetTableReference("test");
            TestTable.CreateIfNotExists();

            DeleteEntities(TestTable, "AAA");
            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
            });
            TestTable.ExecuteBatch(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
            });
            TestTable.ExecuteBatch(batch);

            string serviceBusQueueName = string.Format("test-input-{0}", _testId);
            string connectionString    = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
            var    namespaceManager    = NamespaceManager.CreateFromConnectionString(connectionString);

            namespaceManager.DeleteQueue(serviceBusQueueName);
            namespaceManager.CreateQueue(serviceBusQueueName);

            ServiceBusQueueClient = Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(connectionString, serviceBusQueueName);
        }
            protected override void CreateTestStorageEntities()
            {
                // This will ensure the input container is created.
                base.CreateTestStorageEntities();

                TestBlobContents = "My Test Blob";
                TestBlobName     = Guid.NewGuid().ToString();

                // write the test blob before the host starts, so it gets picked
                // up relatively quickly by the blob trigger test
                CloudBlockBlob inputBlob = TestInputContainer.GetBlockBlobReference(TestBlobName);

                inputBlob.UploadText(TestBlobContents);
            }
        protected virtual void CreateTestStorageEntities()
        {
            TestQueue = QueueClient.GetQueueReference(string.Format("test-input-{0}", FixtureId));
            TestQueue.CreateIfNotExists();
            TestQueue.Clear();

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

            TestInputContainer = BlobClient.GetContainerReference(string.Format("test-input-{0}", FixtureId));
            TestInputContainer.CreateIfNotExists();
            // Processing a large number of blobs on startup can take a while,
            // so let's start with an empty container.
            TestHelpers.ClearContainer(TestInputContainer);

            TestOutputContainer = BlobClient.GetContainerReference(string.Format("test-output-{0}", FixtureId));
            TestOutputContainer.CreateIfNotExists();
            TestHelpers.ClearContainer(TestOutputContainer);

            TestTable = TableClient.GetTableReference("test");
            TestTable.CreateIfNotExists();

            DeleteEntities(TestTable, "AAA");
            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
            });
            TestTable.ExecuteBatch(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
            });
            TestTable.ExecuteBatch(batch);

            string serviceBusQueueName = string.Format("test-input-{0}", FixtureId);
            string connectionString    = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
            var    namespaceManager    = NamespaceManager.CreateFromConnectionString(connectionString);

            namespaceManager.DeleteQueue(serviceBusQueueName);
            namespaceManager.CreateQueue(serviceBusQueueName);

            ServiceBusQueueClient = Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(connectionString, serviceBusQueueName);
        }