public void SetAzureServiceProjectTestsLocationValid()
        {
            string[] locations = { "West US", "East US", "East Asia", "North Europe" };
            foreach (string item in locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    mockCommandRuntime = new MockCommandRuntime();
                    setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                    settings.Save(paths.Settings);

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    Assert.AreEqual <string>(item, settings.Location);
                    ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                    Assert.AreEqual <string>(item, settings.Location);
                }
            }
        }
        public void SetAzureServiceProjectTestsLocationValid()
        {
            string[] locations = { "West US", "East US", "East Asia", "North Europe" };
            foreach (string item in locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    mockCommandRuntime = new MockCommandRuntime();
                    setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                    settings.Save(paths.Settings);

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    Assert.AreEqual<string>(item, settings.Location);
                    ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                    Assert.AreEqual<string>(item, settings.Location);
                }
            }
        }
Exemple #3
0
 public static void AreEqualServicePathInfo(string rootPath, ServicePathInfo actual)
 {
     Assert.AreEqual <string>(rootPath, actual.RootPath);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.ServiceDefinitionFileName), actual.Definition);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.CloudServiceConfigurationFileName), actual.CloudConfiguration);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.LocalServiceConfigurationFileName), actual.LocalConfiguration);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.SettingsFileName), actual.Settings);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.CloudPackageFileName), actual.CloudPackage);
     Assert.AreEqual <string>(Path.Combine(rootPath, Resources.LocalPackageFileName), actual.LocalPackage);
 }
Exemple #4
0
        public static void AddWorkerRoleToDef(string path, Dictionary <string, object> parameters)
        {
            RoleInfo          role       = parameters["Role"] as RoleInfo;
            ServiceComponents components = parameters["Components"] as ServiceComponents;
            ServicePathInfo   paths      = parameters["Paths"] as ServicePathInfo;
            WorkerRole        workerRole = General.DeserializeXmlFile <ServiceDefinition>(path).WorkerRole[0];

            role.AddRoleToDefinition(components.Definition, workerRole);
            components.Save(paths);
        }
 public static void AreEqualServicePathInfo(string rootPath, ServicePathInfo actual)
 {
     Assert.AreEqual<string>(rootPath, actual.RootPath);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.ServiceDefinitionFileName), actual.Definition);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.CloudServiceConfigurationFileName), actual.CloudConfiguration);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.LocalServiceConfigurationFileName), actual.LocalConfiguration);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.SettingsFileName), actual.Settings);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.CloudPackageFileName), actual.CloudPackage);
     Assert.AreEqual<string>(Path.Combine(rootPath, Resources.LocalPackageFileName), actual.LocalPackage);
 }
Exemple #6
0
        public static void AddRoleToConfig(string path, Dictionary <string, object> parameters)
        {
            RoleInfo          role       = parameters["Role"] as RoleInfo;
            ServiceComponents components = parameters["Components"] as ServiceComponents;
            ServicePathInfo   paths      = parameters["Paths"] as ServicePathInfo;
            RoleSettings      settings   = General.DeserializeXmlFile <ServiceConfiguration>(path).Role[0];

            components.AddRoleToConfiguration(settings, DevEnv.Cloud);
            components.AddRoleToConfiguration(settings, DevEnv.Local);
            components.Save(paths);
        }
        public void SetAzureServiceProjectTestsSlotTestsInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows <ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, "MyHome", null, null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Slot"));
            }
        }
        public void SetAzureServiceProjectTestsStorageTestsEmptyFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows <ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, string.Empty, null, paths.Settings), string.Format(Resources.InvalidOrEmptyArgumentMessage, "StorageAccountName"));
            }
        }
        public void AzureSetDeploymentLocationProcessTestsNullFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows <ArgumentException>(() => new SetAzureDeploymentLocationCommand().SetAzureDeploymentLocationProcess(null, paths.Settings), string.Format(Resources.InvalidOrEmptyArgumentMessage, "Location"));
            }
        }
        public void AzureSetDeploymentSlotProcessTestsInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows <ArgumentException>(() => new SetAzureDeploymentSlotCommand().SetAzureDeploymentSlotProcess("MyHome", paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Slot"));
            }
        }
        public void SetAzureServiceProjectTestsLocationInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess("MyHome", null, null, null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Location"));
            }
        }
 public void ServicePathInfoTestNullRootPathFail()
 {
     try
     {
         ServicePathInfo paths = new ServicePathInfo(null);
         Assert.Fail("No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex is ArgumentException);
         Assert.AreEqual <string>(string.Format(Resources.InvalidOrEmptyArgumentMessage, "service root"), ex.Message);
     }
 }
 public void ServicePathInfoTestNullRootPathFail()
 {
     try
     {
         ServicePathInfo paths = new ServicePathInfo(null);
         Assert.Fail("No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex is ArgumentException);
         Assert.AreEqual<string>(string.Format(Resources.InvalidOrEmptyArgumentMessage, "service definition (*.csdef) file"), ex.Message);
     }
 }
        public void SetAzureServiceProjectTestsLocationEmptyFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(string.Empty, null, null, paths.Settings), string.Format(Resources.InvalidOrEmptyArgumentMessage, "Location"));
            }
        }
 public void ServicePathInfoTestInvalidRootPathFail()
 {
     foreach (string invalidDirectoryName in Data.InvalidServiceRootName)
     {
         try
         {
             ServicePathInfo paths = new ServicePathInfo(invalidDirectoryName);
             Assert.Fail("No exception was thrown");
         }
         catch (Exception ex)
         {
             Assert.IsTrue(ex is ArgumentException);
             Assert.AreEqual <string>(Resources.InvalidRootNameMessage, ex.Message);
         }
     }
 }
 public void ServicePathInfoTestInvalidRootPathFail()
 {
     foreach (string invalidDirectoryName in Data.InvalidServiceRootName)
     {
         try
         {
             ServicePathInfo paths = new ServicePathInfo(invalidDirectoryName);
             Assert.Fail("No exception was thrown");
         }
         catch (Exception ex)
         {
             Assert.IsTrue(ex is ArgumentException);
             Assert.AreEqual<string>(Resources.InvalidRootNameMessage, ex.Message);
         }
     }
 }
Exemple #17
0
        public void ServiceComponentsTestLocalConfigDoesNotExistFail()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            ServicePathInfo paths = new ServicePathInfo(serviceName);

            try
            {
                File.Delete(paths.LocalConfiguration);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is FileNotFoundException);
                Assert.AreEqual <string>(string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.LocalConfiguration), ex.Message);
            }
        }
        public void ServiceComponentsTestCloudConfigDoesNotExistFail()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            ServicePathInfo paths = new ServicePathInfo(serviceName);

            try
            {
                File.Delete(paths.CloudConfiguration);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is FileNotFoundException);
                Assert.AreEqual<string>(ex.Message, string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.CloudConfiguration));
            }
        }
        public void AzureSetDeploymentStorageAccountNameProcessTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                new SetAzureDeploymentStorageCommand().SetAzureDeploymentStorageProcess("companystore", paths.Settings);

                // Assert storageAccountName is changed
                //
                settings = ServiceSettings.Load(paths.Settings);
                Assert.AreEqual <string>("companystore", settings.StorageAccountName);
            }
        }
        public void SetAzureServiceProjectTestsUnknownLocation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);
                string unknownLocation = "Unknown Location";

                settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(unknownLocation, null, null, null, paths.Settings);

                // Assert location is changed
                //
                Assert.AreEqual <string>(unknownLocation, settings.Location);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.AreEqual <string>(unknownLocation, settings.Location);
            }
        }
        /// <summary>
        /// Set the runtime properties for a role
        /// </summary>
        /// <param name="definition">The service containing the role</param>
        /// <param name="roleName">The name of the role to change</param>
        /// <param name="path">The path to the service</param>
        /// <param name="version">The version of the runtime to be installed</param>
        /// <param name="overrideUrl">The value of the override url, if the user wants to opt out of the system</param>
        /// <returns>true if the settings were successfully changed</returns>
        public static bool SetRoleRuntime(ServiceDefinition definition, string roleName, ServicePathInfo path, string version = null, string overrideUrl = null)
        {
            bool changed = false;
            Variable[] environment = GetRoleRuntimeEnvironment(definition, roleName);
            if (version != null)
            {
                string filePath = Path.Combine(path.RootPath, roleName, "package.json");
                File.WriteAllText(filePath, string.Format(TestResources.ValidPackageJson, "testapp", version));
                changed = true;
            }


            if (overrideUrl != null)
            {
                environment = SetRuntimeEnvironment(environment, Resources.RuntimeOverrideKey, overrideUrl);
                changed = true;
            }

            return changed && ApplyRuntimeChanges(definition, roleName, environment);
        }
        public void AzureSetDeploymentSlotProcessTests()
        {
            foreach (KeyValuePair <Slot, string> item in AzureDeploymentCmdlets.Model.ArgumentConstants.Slots)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureDeploymentSlotCommand().SetAzureDeploymentSlotProcess(item.Value, paths.Settings);

                    // Assert slot is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual <string>(item.Value, settings.Slot);
                }
            }
        }
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                mockCommandRuntime = new MockCommandRuntime();
                setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                settings.Save(paths.Settings);

                settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, "companystore", null, paths.Settings);

                // Assert storageAccountName is changed
                //
                Assert.AreEqual <string>("companystore", settings.StorageServiceName);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.AreEqual <string>("companystore", settings.StorageServiceName);
            }
        }
        public void SetAzureServiceProjectTestsLocationValid()
        {
            foreach (KeyValuePair<Location, string> item in Microsoft.WindowsAzure.Management.CloudService.Model.ArgumentConstants.Locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess(item.Value, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual<string>(item.Value, settings.Location);
                }
            }
        }
        public void AzureSetDeploymentSubscriptionProcessTests()
        {
            foreach (string item in Data.ValidSubscriptionName)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureDeploymentSubscriptionCommand().SetAzureDeploymentSubscriptionProcess(item, paths.Settings);

                    // Assert subscription is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual <string>(item, settings.Subscription);
                }
            }
        }
Exemple #26
0
        public void SetAzureServiceProjectTestsLocationValid()
        {
            foreach (KeyValuePair <Location, string> item in Microsoft.WindowsAzure.Management.CloudService.Model.ArgumentConstants.Locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess(item.Value, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual <string>(item.Value, settings.Location);
                }
            }
        }
        public void SetAzureServiceProjectTestsSlotTests()
        {
            string[] slots = { DeploymentSlotType.Production, DeploymentSlotType.Staging };
            foreach (string item in slots)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, item, null, null, paths.Settings);

                    // Assert slot is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual <string>(item, settings.Slot);
                }
            }
        }
        public void SetAzureServiceProjectTestsSubscriptionValid()
        {
            foreach (string item in Data.ValidSubscriptionName)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);
                    setServiceProjectCmdlet.PassThru = false;

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, null, item, paths.Settings);

                    // Assert subscription is changed
                    //
                    Assert.AreEqual<string>(item, settings.Subscription);
                    Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
                }
            }
        }
        public void SetAzureServiceProjectTestsSubscriptionValid()
        {
            foreach (string item in Data.ValidSubscriptionName)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths    = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);
                    setServiceProjectCmdlet.PassThru = false;

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, null, item, paths.Settings);

                    // Assert subscription is changed
                    //
                    Assert.AreEqual <string>(item, settings.Subscription);
                    Assert.AreEqual <int>(0, mockCommandRuntime.OutputPipeline.Count);
                }
            }
        }
        public void SetAzureServiceProjectTestsLocationValid()
        {
            foreach (KeyValuePair<LocationName, string> item in ArgumentConstants.Locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    mockCommandRuntime = new MockCommandRuntime();
                    setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                    settings.Save(paths.Settings);

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item.Value, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    Assert.AreEqual<string>(item.Value, settings.Location);
                    ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                    Assert.AreEqual<string>(item.Value, settings.Location);
                }
            }
        }
Exemple #31
0
 public static void AreEqualServicePathInfo(string cloudConfig, string cloudPackage, string def, string localConfig, string localPackage, string rootPath, string settings, ServicePathInfo actual)
 {
     throw new NotImplementedException();
 }
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                mockCommandRuntime = new MockCommandRuntime();
                setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                settings.Save(paths.Settings);

                settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, "companystore", paths.Settings);

                // Assert storageAccountName is changed
                //
                Assert.AreEqual<string>("companystore", settings.StorageServiceName);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.AreEqual<string>("companystore", settings.StorageServiceName);
            }
        }
Exemple #33
0
        /// <summary>
        /// Set the runtime properties for a role
        /// </summary>
        /// <param name="definition">The service containing the role</param>
        /// <param name="roleName">The name of the role to change</param>
        /// <param name="path">The path to the service</param>
        /// <param name="version">The version of the runtime to be installed</param>
        /// <param name="overrideUrl">The value of the override url, if the user wants to opt out of the system</param>
        /// <returns>true if the settings were successfully changed</returns>
        public static bool SetRoleRuntime(ServiceDefinition definition, string roleName, ServicePathInfo path, string version = null, string overrideUrl = null)
        {
            bool changed = false;

            Variable[] environment = GetRoleRuntimeEnvironment(definition, roleName);
            if (version != null)
            {
                string filePath = Path.Combine(path.RootPath, roleName, "package.json");
                File.WriteAllText(filePath, string.Format(TestResources.ValidPackageJson, "testapp", version));
                changed = true;
            }


            if (overrideUrl != null)
            {
                environment = SetRuntimeEnvironment(environment, Resources.RuntimeOverrideKey, overrideUrl);
                changed     = true;
            }

            return(changed && ApplyRuntimeChanges(definition, roleName, environment));
        }
 public void ServicePathInfoTest()
 {
     ServicePathInfo paths = new ServicePathInfo("MyService");
     AzureAssert.AreEqualServicePathInfo("MyService", paths);
 }
        public void SetAzureServiceProjectTestsSlotTests()
        {
            string[] slots = { DeploymentSlotType.Production, DeploymentSlotType.Staging };
            foreach (string item in slots)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, item, null, paths.Settings);

                    // Assert slot is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual<string>(item, settings.Slot);
                }
            }
        }
 public static void AreEqualServicePathInfo(string cloudConfig, string cloudPackage, string def, string localConfig, string localPackage, string rootPath, string settings, ServicePathInfo actual)
 {
     throw new NotImplementedException();
 }
        public void SetAzureServiceProjectTestsSlotTests()
        {
            foreach (KeyValuePair<SlotType, string> item in ArgumentConstants.Slots)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, item.Value, null, null, paths.Settings);

                    // Assert slot is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual<string>(item.Value, settings.Slot);
                }
            }
        }
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                writer = new FakeWriter();
                cmdlet.Writer = writer;
                settings.Save(paths.Settings);

                settings = cmdlet.SetAzureServiceProjectProcess(null, null, "companystore", null, paths.Settings);

                // Assert storageAccountName is changed
                //
                Assert.AreEqual<string>("companystore", settings.StorageAccountName);
                ServiceSettings actualOutput = writer.OutputChannel[0] as ServiceSettings;
                Assert.AreEqual<string>("companystore", settings.StorageAccountName);
            }
        }
 public static void AreEqualServicePathInfo(ServicePathInfo expected, ServicePathInfo actual)
 {
     AreEqualServicePathInfo(expected.CloudConfiguration, expected.CloudPackage, expected.Definition, expected.LocalConfiguration,
         expected.LocalPackage, expected.RootPath, expected.Settings, actual);
 }
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess(null, null, "companystore", null, paths.Settings);

                // Assert storageAccountName is changed
                //
                settings = ServiceSettings.Load(paths.Settings);
                Assert.AreEqual<string>("companystore", settings.StorageAccountName);
            }
        }
        public void SetAzureServiceProjectTestsSubscriptionValid()
        {
            foreach (string item in Data.ValidSubscriptionNames)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    writer = new FakeWriter();
                    cmdlet.Writer = writer;
                    settings.Save(paths.Settings);

                    settings = cmdlet.SetAzureServiceProjectProcess(null, null, null, item, paths.Settings);

                    // Assert subscription is changed
                    //
                    Assert.AreEqual<string>(item, settings.Subscription);
                    ServiceSettings actualOutput = writer.OutputChannel[0] as ServiceSettings;
                    Assert.AreEqual<string>(item, actualOutput.Subscription);
                }
            }
        }
        public void SetAzureServiceProjectTestsSubscriptionValid()
        {
            foreach (string item in Data.ValidSubscriptionName)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess(null, null, null, item, paths.Settings);

                    // Assert subscription is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual<string>(item, settings.Subscription);
                }
            }
        }
        public void ServicePathInfoTest()
        {
            ServicePathInfo paths = new ServicePathInfo("MyService");

            AzureAssert.AreEqualServicePathInfo("MyService", paths);
        }
        public void SetAzureServiceProjectTestsUnknownLocation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);
                string unknownLocation = "Unknown Location";

                settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(unknownLocation, null, null, paths.Settings);

                // Assert location is changed
                //
                Assert.AreEqual<string>(unknownLocation, settings.Location);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.AreEqual<string>(unknownLocation, settings.Location);
            }
        }
        public void ServiceComponentsTestSettingsDoesNotExistFail()
        {
            new NewAzureServiceProjectCommand().NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            ServicePathInfo paths = new ServicePathInfo(serviceName);

            try
            {
                File.Delete(paths.Definition);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is FileNotFoundException);
                Assert.AreEqual<string>(string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceDefinition, paths.Definition), ex.Message);
            }
        }
Exemple #46
0
 public static void AreEqualServicePathInfo(ServicePathInfo expected, ServicePathInfo actual)
 {
     AreEqualServicePathInfo(expected.CloudConfiguration, expected.CloudPackage, expected.Definition, expected.LocalConfiguration,
                             expected.LocalPackage, expected.RootPath, expected.Settings, actual);
 }