public void AddAzureWebRoleWillRecreateDeploymentSettings() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string settingsFilePath = Path.Combine(rootPath, Resources.SettingsFileName); string originalDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(rootPath); File.Delete(settingsFilePath); Assert.IsFalse(File.Exists(settingsFilePath)); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName }; addWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WebRole)); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Assert.IsTrue(File.Exists(settingsFilePath)); Directory.SetCurrentDirectory(originalDirectory); } }
public void AddAzureWebRoleWithMissingScaffoldXmlFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); string scaffoldingPath = "TemplateMissingScaffoldXml"; addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Testing.AssertThrows<FileNotFoundException>(() => addWebCmdlet.ExecuteCmdlet()); } }
public void AddAzureWebRoleWithTemplateFolder() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); string scaffoldingPath = "MyWebTemplateFolder"; Directory.SetCurrentDirectory(rootPath); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; addWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), scaffoldingPath); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Directory.SetCurrentDirectory(originalDirectory); } }