Exemplo n.º 1
0
        public async Task GetAccountAsync_WhenNoStorage_Succeeds()
        {
            DefaultStorageAccountProvider provider = CreateProductUnderTest();

            provider.DashboardConnectionString = null;
            provider.StorageConnectionString   = null;

            var dashboardAccount = await provider.GetAccountAsync(ConnectionStringNames.Dashboard, CancellationToken.None);

            Assert.Null(dashboardAccount);

            var storageAccount = await provider.GetAccountAsync(ConnectionStringNames.Storage, CancellationToken.None);

            Assert.Null(storageAccount);
        }
Exemplo n.º 2
0
        public async Task GetAccountAsync_WhenStorageOverriddenWithNull_Succeeds()
        {
            DefaultStorageAccountProvider provider = CreateProductUnderTest();

            provider.StorageConnectionString = null;

            var account = await provider.GetAccountAsync(ConnectionStringNames.Storage, CancellationToken.None);

            Assert.Null(account);
        }
Exemplo n.º 3
0
        public void GetAccountAsync_WhenDashboardOverriddenWithNull_ReturnsNull()
        {
            DefaultStorageAccountProvider provider = CreateProductUnderTest();

            provider.DashboardConnectionString = null;

            IStorageAccount actualAccount = provider.GetAccountAsync(
                ConnectionStringNames.Dashboard, CancellationToken.None).GetAwaiter().GetResult();

            Assert.Null(actualAccount);
        }
Exemplo n.º 4
0
        public void GetAccountAsync_WhenDashboardOverridden_ReturnsParsedAccount()
        {
            IConnectionStringProvider connectionStringProvider = CreateDummyConnectionStringProvider();
            string                        connectionString     = "valid-ignore";
            IStorageAccount               parsedAccount        = Mock.Of <IStorageAccount>();
            IServiceProvider              services             = CreateServices();
            IStorageAccountParser         parser    = CreateParser(services, ConnectionStringNames.Dashboard, connectionString, parsedAccount);
            IStorageCredentialsValidator  validator = CreateValidator(parsedAccount);
            DefaultStorageAccountProvider provider  = CreateProductUnderTest(services, connectionStringProvider, parser, validator);

            provider.DashboardConnectionString = connectionString;
            IStorageAccount actualAccount = provider.GetAccountAsync(
                ConnectionStringNames.Dashboard, CancellationToken.None).GetAwaiter().GetResult();

            Assert.Same(parsedAccount, actualAccount);
        }
Exemplo n.º 5
0
        public void GetAccountAsync_WhenStorageOverriddenWithNull_Throws()
        {
            DefaultStorageAccountProvider provider = CreateProductUnderTest();

            provider.StorageConnectionString = null;

            ExceptionAssert.ThrowsInvalidOperation(() => provider.GetAccountAsync(
                                                       ConnectionStringNames.Storage, CancellationToken.None).GetAwaiter().GetResult(),
                                                   @"Microsoft Azure WebJobs SDK Storage connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways:" +
                                                   Environment.NewLine +
                                                   @"1. Set the connection string named 'AzureWebJobsStorage' in the connectionStrings section of the .config file in the following format <add name=""AzureWebJobsStorage"" connectionString=""DefaultEndpointsProtocol=http|https;AccountName=NAME;AccountKey=KEY"" />, or" +
                                                   Environment.NewLine +
                                                   @"2. Set the environment variable named 'AzureWebJobsStorage', or" +
                                                   Environment.NewLine +
                                                   @"3. Set corresponding property of JobHostConfiguration.");
        }