Exemplo n.º 1
0
            public TestFixture()
            {
                DefaultStorageAccountProvider accountProvider = new DefaultStorageAccountProvider();
                var task = accountProvider.GetStorageAccountAsync(CancellationToken.None);

                task.Wait();
                IStorageQueueClient client = task.Result.CreateQueueClient();

                QueueClient = client.SdkObject;

                string queueName = string.Format("{0}-{1}", TestQueuePrefix, Guid.NewGuid());

                Queue = client.GetQueueReference(queueName).SdkObject;
                Queue.CreateIfNotExistsAsync(CancellationToken.None).Wait();

                string poisonQueueName = string.Format("{0}-poison", queueName);

                PoisonQueue = client.GetQueueReference(poisonQueueName).SdkObject;
                PoisonQueue.CreateIfNotExistsAsync(CancellationToken.None).Wait();
            }
            public TestFixture()
            {
                Mock <IServiceProvider> services      = new Mock <IServiceProvider>(MockBehavior.Strict);
                StorageClientFactory    clientFactory = new StorageClientFactory();

                services.Setup(p => p.GetService(typeof(StorageClientFactory))).Returns(clientFactory);

                DefaultStorageAccountProvider accountProvider = new DefaultStorageAccountProvider(services.Object);
                var task = accountProvider.GetStorageAccountAsync(CancellationToken.None);
                IStorageQueueClient client = task.Result.CreateQueueClient();

                QueueClient = client.SdkObject;

                string queueName = string.Format("{0}-{1}", TestQueuePrefix, Guid.NewGuid());

                Queue = client.GetQueueReference(queueName).SdkObject;
                Queue.CreateIfNotExistsAsync(null, null, CancellationToken.None).Wait();

                string poisonQueueName = string.Format("{0}-poison", queueName);

                PoisonQueue = client.GetQueueReference(poisonQueueName).SdkObject;
                PoisonQueue.CreateIfNotExistsAsync(null, null, CancellationToken.None).Wait();
            }
        public async Task GetAccountAsync_WhenWebJobsStorageAccountNotGeneral_Throws()
        {
            string connectionString = "valid-ignore";
            var    connStringMock   = new Mock <IConnectionStringProvider>();

            connStringMock.Setup(c => c.GetConnectionString(ConnectionStringNames.Storage)).Returns(connectionString);
            var connectionStringProvider = connStringMock.Object;
            var accountMock = new Mock <IStorageAccount>();

            accountMock.SetupGet(s => s.Type).Returns(StorageAccountType.BlobOnly);
            accountMock.SetupGet(s => s.Credentials).Returns(new StorageCredentials("name", string.Empty));
            var parsedAccount = accountMock.Object;
            IServiceProvider              services  = CreateServices();
            IStorageAccountParser         parser    = CreateParser(services, ConnectionStringNames.Storage, connectionString, parsedAccount);
            IStorageCredentialsValidator  validator = CreateValidator(parsedAccount);
            DefaultStorageAccountProvider provider  = CreateProductUnderTest(services, connectionStringProvider, parser, validator);
            var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => provider.GetStorageAccountAsync(CancellationToken.None));

            Assert.Equal("Storage account 'name' is of unsupported type 'Blob-Only/ZRS'. Supported types are 'General Purpose'", exception.Message);
        }