public void GetStorageAccountsTestEmptyList()
        {
            SimpleServiceManagement channel = new SimpleServiceManagement();

            channel.ListStorageServicesThunk = ar => new StorageServiceList();
            GetAzureStorageAccountsCommand cmd = new GetAzureStorageAccountsCommand(channel);

            string result = cmd.GetStorageServicesProcess("TestSubscription1");

            Assert.IsTrue(string.IsNullOrEmpty(result));
        }
        public void GetStorageAccountsTestManyEntriesList()
        {
            SimpleServiceManagement channel = new SimpleServiceManagement();
            string expectedResult           = CreateExpectedResult(Data.ValidStorageService);

            channel.ListStorageServicesThunk = ar => Data.ValidStorageService;
            channel.GetStorageKeysThunk      = ar => Data.ValidStorageService[0];
            GetAzureStorageAccountsCommand cmd = new GetAzureStorageAccountsCommand(channel);

            string actualResult = cmd.GetStorageServicesProcess("TestSubscription1");

            Assert.AreEqual <string>(expectedResult, actualResult);
        }
        public void GetStorageAccountsTestEmptySubscriptionFail()
        {
            string doesNotExistSubscription = "DoesNotExistSubscription";
            string argumentErrorExpectedMsg = string.Format(Resources.SubscriptionIdNotFoundMessage, doesNotExistSubscription, Path.Combine(Data.AzureSdkAppDir, Resources.PublishSettingsFileName));

            try
            {
                new ImportAzurePublishSettingsCommand().ImportAzurePublishSettingsProcess(Resources.PublishSettingsFileName, Data.AzureSdkAppDir);
                SimpleServiceManagement channel = new SimpleServiceManagement();
                channel.ListStorageServicesThunk = ar => new StorageServiceList();
                GetAzureStorageAccountsCommand cmd = new GetAzureStorageAccountsCommand(channel);

                string result = cmd.GetStorageServicesProcess("DoesNotExistSubscription");
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual <string>(argumentErrorExpectedMsg, ex.Message);
            }
        }
        public void GetStorageAccountsTestOneEntryList()
        {
            SimpleServiceManagement channel = new SimpleServiceManagement();
            StorageServiceList      list    = new StorageServiceList();

            list.Add(Data.ValidStorageService[0]);
            StringBuilder expectedResult = new StringBuilder();

            expectedResult.AppendFormat("{0, -16}{1}", Resources.StorageAccountName, list[0].ServiceName);
            expectedResult.AppendLine();
            expectedResult.AppendFormat("{0, -16}{1}", Resources.StoragePrimaryKey, list[0].StorageServiceKeys.Primary);
            expectedResult.AppendLine();
            expectedResult.AppendFormat("{0, -16}{1}", Resources.StorageSecondaryKey, list[0].StorageServiceKeys.Secondary);
            channel.ListStorageServicesThunk = ar => list;
            channel.GetStorageKeysThunk      = ar => list[0];
            GetAzureStorageAccountsCommand cmd = new GetAzureStorageAccountsCommand(channel);

            string actualResult = cmd.GetStorageServicesProcess("TestSubscription1");

            Assert.AreEqual <string>(expectedResult.ToString(), actualResult);
        }