public static async Task <DataStore> SetupDatastore(DataStore dataStore)
        {
            var subscriptionResult = await TestHarness.ExecuteActionAsync("Microsoft-GetAzureSubscriptions", dataStore);

            Assert.IsTrue(subscriptionResult.IsSuccess);
            var subscriptionId =
                subscriptionResult.Body.GetJObject()["value"].SingleOrDefault(
                    p => p["DisplayName"].ToString() == "Project Essex");

            dataStore.AddToDataStore("SelectedSubscription", subscriptionId, DataStoreType.Public);

            var locationResult = await TestHarness.ExecuteActionAsync("Microsoft-GetLocations", dataStore);

            Assert.IsTrue(locationResult.IsSuccess);
            var location = locationResult.Body.GetJObject()["value"][12];

            dataStore.AddToDataStore("SelectedLocation", location, DataStoreType.Public);


            if (System.Diagnostics.Debugger.IsAttached)
            {
                ResourceGroup = Environment.MachineName;
            }


            if (System.Diagnostics.Debugger.IsAttached)
            {
                ResourceGroup = Environment.MachineName + RandomGenerator.GetRandomLowerCaseCharacters(5);
            }

            dataStore.AddToDataStore("SelectedResourceGroup", ResourceGroup);


            if (!System.Diagnostics.Debugger.IsAttached)
            {
                var deleteResourceGroupResult = await TestHarness.ExecuteActionAsync("Microsoft-DeleteResourceGroup", dataStore);
            }

            var resourceGroupResult = await TestHarness.ExecuteActionAsync("Microsoft-CreateResourceGroup", dataStore);

            Assert.IsTrue(resourceGroupResult.IsSuccess);
            return(dataStore);
        }
        public static string GetSqlPagePayload(string database)
        {
            var dataStore = new DataStore();

            dynamic sqlPayload = new ExpandoObject();

            sqlPayload.SqlCredentials          = new ExpandoObject();
            sqlPayload.SqlCredentials.Server   = Credential.Instance.Sql.Server;
            sqlPayload.SqlCredentials.AuthType = "azuresql";
            sqlPayload.SqlCredentials.User     = Credential.Instance.Sql.Username;
            sqlPayload.SqlCredentials.Password = Credential.Instance.Sql.Password;
            sqlPayload.SqlCredentials.Database = database;

            dataStore.AddObjectDataStore("SqlCredentials", JsonUtility.GetJObjectFromObject(sqlPayload), DataStoreType.Any);

            ActionResponse sqlResponse = TestHarness.ExecuteAction("Microsoft-GetSqlConnectionString", dataStore);

            Assert.IsTrue(sqlResponse.Status == ActionStatus.Success);

            return((sqlResponse.Body as JObject)["value"].ToString());
        }
        public static async Task <DataStore> SetupDatastore(DataStore dataStore)
        {
            var subscriptionResult = await TestHarness.ExecuteActionAsync("Microsoft-GetAzureSubscriptions", dataStore);

            Assert.IsTrue(subscriptionResult.IsSuccess);
            var subscriptionId =
                subscriptionResult.Body.GetJObject()["value"].SingleOrDefault(
                    p => p["DisplayName"].ToString().StartsWith("PBI_"));

            dataStore.AddToDataStore("SelectedSubscription", subscriptionId, DataStoreType.Public);

            var locationResult = await TestHarness.ExecuteActionAsync("Microsoft-GetLocations", dataStore);

            Assert.IsTrue(locationResult.IsSuccess, "LocationResult failed.  Error: {0}", locationResult.ExceptionDetail != null ? locationResult.ExceptionDetail.ExceptionCaught : null);
            var location = locationResult.Body.GetJObject()["value"][5];

            dataStore.AddToDataStore("SelectedLocation", location, DataStoreType.Public);


            if (System.Diagnostics.Debugger.IsAttached)
            {
                ResourceGroup = Environment.MachineName;
            }


            dataStore.AddToDataStore("SelectedResourceGroup", ResourceGroup);


            if (!System.Diagnostics.Debugger.IsAttached)
            {
                var deleteResourceGroupResult = await TestHarness.ExecuteActionAsync("Microsoft-DeleteResourceGroup", dataStore);
            }

            var resourceGroupResult = await TestHarness.ExecuteActionAsync("Microsoft-CreateResourceGroup", dataStore);

            Assert.IsTrue(resourceGroupResult.IsSuccess);
            return(dataStore);
        }