private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName) { Components.Definition.name = serviceName; Components.CloudConfig.serviceName = serviceName; Components.LocalConfig.serviceName = serviceName; Components.Save(paths); }
public AzureService(string rootPath, string scaffoldingPath) { SetScaffolding(scaffoldingPath); Paths = new ServicePathInfo(rootPath); Components = new ServiceComponents(Paths); packageTool = new CsPack(); runTool = new CsRun(); }
public void ChangeServiceName(string newName, ServicePathInfo paths) { Validate.ValidateDnsName(newName, "service name"); Components.Definition.name = newName; Components.CloudConfig.serviceName = newName; Components.LocalConfig.serviceName = newName; Components.Save(paths); }
public void Save(ServicePathInfo paths) { if (paths == null) throw new ArgumentNullException("paths"); // Validate directory exists and it's valid General.SerializeXmlFile<ServiceDefinition>(Definition, paths.Definition); General.SerializeXmlFile<ServiceConfiguration>(CloudConfig, paths.CloudConfiguration); General.SerializeXmlFile<ServiceConfiguration>(LocalConfig, paths.LocalConfiguration); Settings.Save(paths.Settings); }
public void AzureSetDeploymentLocationProcessTestsEmptyFail() { 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(string.Empty, 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")); } }
private void LoadComponents(ServicePathInfo paths) { Validate.ValidateNullArgument(paths, string.Format(Resources.NullObjectMessage, "paths")); Validate.ValidateFileFull(paths.CloudConfiguration, Resources.ServiceConfiguration); Validate.ValidateFileFull(paths.LocalConfiguration, Resources.ServiceConfiguration); Validate.ValidateFileFull(paths.Definition, Resources.ServiceDefinition); Validate.ValidateFileFull(paths.Settings, Resources.ServiceSettings); Definition = General.DeserializeXmlFile<ServiceDefinition>(paths.Definition); CloudConfig = General.DeserializeXmlFile<ServiceConfiguration>(paths.CloudConfiguration); LocalConfig = General.DeserializeXmlFile<ServiceConfiguration>(paths.LocalConfiguration); Settings = ServiceSettings.Load(paths.Settings); }
public void ServiceComponentsTestDefinitionDoesNotExistFail() { new NewAzureServiceCommand().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); } }
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 AzureService(string serviceParentDirectory, string name, string scaffoldingPath) : this() { Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory); Validate.ValidateStringIsNullOrEmpty(name, "Name"); Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name")); Validate.ValidateDnsName(name, "Name"); string newServicePath = Path.Combine(serviceParentDirectory, name); if (Directory.Exists(newServicePath)) { throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath)); } packageTool = new CsPack(); SetScaffolding(scaffoldingPath); Paths = new ServicePathInfo(newServicePath); CreateNewService(Paths.RootPath, name); Components = new ServiceComponents(Paths); ConfigureNewService(Components, Paths, name); }
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 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); } } }
public void SetRoleInstances(ServicePathInfo paths, string roleName, int instances) { Components.SetRoleInstances(roleName, instances); Components.Save(paths); }
public ServiceComponents(ServicePathInfo paths) { LoadComponents(paths); }
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 static void AreEqualServicePathInfo(string cloudConfig, string cloudPackage, string def, string localConfig, string localPackage, string root, string settings, ServicePathInfo actual) { throw new NotImplementedException(); }
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); }