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
                    //
                    PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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);
                }
            }
        }
Esempio n. 2
0
        public static void AddWorkerRoleToDef(string path, Dictionary <string, object> parameters)
        {
            RoleInfo                  role       = parameters["Role"] as RoleInfo;
            ServiceComponents         components = parameters["Components"] as ServiceComponents;
            PowerShellProjectPathInfo paths      = parameters["Paths"] as PowerShellProjectPathInfo;
            WorkerRole                workerRole = General.DeserializeXmlFile <ServiceDefinition>(path).WorkerRole[0];

            role.AddRoleToDefinition(components.Definition, workerRole);
            components.Save(paths);
        }
Esempio n. 3
0
        public static void AddRoleToConfig(string path, Dictionary <string, object> parameters)
        {
            RoleInfo                  role       = parameters["Role"] as RoleInfo;
            ServiceComponents         components = parameters["Components"] as ServiceComponents;
            PowerShellProjectPathInfo paths      = parameters["Paths"] as PowerShellProjectPathInfo;
            RoleSettings              settings   = General.DeserializeXmlFile <ServiceConfiguration>(path).Role[0];

            components.AddRoleToConfiguration(settings, DevEnv.Cloud);
            components.AddRoleToConfiguration(settings, DevEnv.Local);
            components.Save(paths);
        }
Esempio n. 4
0
 public void ServicePathInfoTestNullRootPathFail()
 {
     try
     {
         PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(null);
         Assert.True(false, "No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.True(ex is ArgumentException);
         Assert.Equal <string>(string.Format(Resources.InvalidOrEmptyArgumentMessage, "rootPath"), ex.Message);
     }
 }
Esempio n. 5
0
        public void SetAzureServiceProjectTestsSlotTestsInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths    = new PowerShellProjectPathInfo(files.RootPath);
                ServiceSettings           settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows <ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, "MyHome", null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Slot"));
            }
        }
 public void ServicePathInfoTestNullRootPathFail()
 {
     try
     {
         PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(null);
         Assert.Fail("No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex is ArgumentException);
         Assert.AreEqual<string>(string.Format(Resources.InvalidOrEmptyArgumentMessage, "rootPath"), ex.Message);
     }
 }
Esempio n. 7
0
        public void SetAzureServiceProjectTestsLocationEmptyFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths    = new PowerShellProjectPathInfo(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 SetAzureServiceProjectTestsLocationEmptyFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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"));
            }
        }
Esempio n. 9
0
 public void ServicePathInfoTestInvalidRootPathFail()
 {
     foreach (string invalidDirectoryName in Test.Utilities.Common.Data.InvalidServiceRootName)
     {
         try
         {
             PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(invalidDirectoryName);
             Assert.True(false, "No exception was thrown");
         }
         catch (Exception ex)
         {
             Assert.True(ex is ArgumentException);
             Assert.Equal <string>(Resources.InvalidRootNameMessage, ex.Message);
         }
     }
 }
 public void ServicePathInfoTestInvalidRootPathFail()
 {
     foreach (string invalidDirectoryName in Data.InvalidServiceRootName)
     {
         try
         {
             PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(invalidDirectoryName);
             Assert.Fail("No exception was thrown");
         }
         catch (Exception ex)
         {
             Assert.IsTrue(ex is ArgumentException);
             Assert.AreEqual<string>(Resources.InvalidRootNameMessage, ex.Message);
         }
     }
 }
Esempio n. 11
0
        public void ServiceComponentsTestCloudConfigDoesNotExistFail()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(serviceName);

            try
            {
                File.Delete(paths.CloudConfiguration);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.True(false, "No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.True(ex is FileNotFoundException);
                Assert.Equal <string>(ex.Message, string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.CloudConfiguration));
            }
        }
        public void ServiceComponentsTestSettingsDoesNotExistFail()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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);
            }
        }
        public void ServiceComponentsTestCloudConfigDoesNotExistFail()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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));
            }
        }
Esempio n. 14
0
        public void ServiceComponentsTestCloudConfigDoesNotExistFail()
        {
            TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
            newServiceCmdlet.NewAzureServiceProcess(TestMockSupport.TestExecutionFolder, serviceName);
            PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serviceName));

            try
            {
                File.Delete(paths.CloudConfiguration);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.True(false, "No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.True(ex is FileNotFoundException);
                Assert.Equal <string>(ex.Message, string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.CloudConfiguration));
            }
        }
Esempio n. 15
0
        public void SetAzureServiceProjectTestsUnknownLocation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths    = new PowerShellProjectPathInfo(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.Equal <string>(unknownLocation, settings.Location);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.Equal <string>(unknownLocation, settings.Location);
            }
        }
Esempio n. 16
0
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths    = new PowerShellProjectPathInfo(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.Equal <string>("companystore", settings.StorageServiceName);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.Equal <string>("companystore", settings.StorageServiceName);
            }
        }
Esempio n. 17
0
        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
                    //
                    PowerShellProjectPathInfo paths    = new PowerShellProjectPathInfo(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.Equal <string>(item, settings.Slot);
                }
            }
        }
 public void ServicePathInfoTest()
 {
     PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo("MyService");
     AzureAssert.AreEqualServicePathInfo("MyService", paths);
 }
        public void SetAzureServiceProjectTestsStorageTests()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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);
            }
        }
        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
                    //
                    PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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 void SetAzureServiceProjectTestsSlotTestsInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, "MyHome", null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Slot"));
            }
        }
Esempio n. 22
0
        public void ServicePathInfoTest()
        {
            PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo("MyService");

            AzureAssert.AreEqualServicePathInfo("MyService", paths);
        }
        public void SetAzureServiceProjectTestsUnknownLocation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(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);
            }
        }