public override void ExecuteCmdlet() { string path = GalleryTemplatesClient.DownloadGalleryTemplateFile( Identity, string.IsNullOrEmpty(Path) ? System.IO.Path.Combine(CurrentPath(), Identity) : this.TryResolvePath(Path), Force, ConfirmAction); WriteObject(PowerShellUtilities.ConstructPSObject(null, "Path", path)); }
public override void ExecuteCmdlet() { WriteWarning("This cmdlet is being deprecated and will be removed in a future release."); string path = GalleryTemplatesClient.DownloadGalleryTemplateFile( Identity, string.IsNullOrEmpty(Path) ? System.IO.Path.Combine(CurrentPath(), Identity) : this.TryResolvePath(Path), Force, ConfirmAction); WriteObject(PowerShellUtilities.ConstructPSObject(null, "Path", path)); }
public void DownloadsGalleryTemplateFile() { string galleryTemplateFileName = "myFile"; string expectedFilePath = Path.Combine(Path.GetTempPath(), galleryTemplateFileName + ".json"); try { galleryClientMock.Setup(f => f.Items.GetAsync(galleryTemplateFileName, new CancellationToken())) .Returns(Task.Factory.StartNew(() => new ItemGetParameters() { Item = new GalleryItem() { Name = galleryTemplateFileName, Publisher = "Microsoft", DefinitionTemplates = new DefinitionTemplates() { DefaultDeploymentTemplateId = "DefaultUri", DeploymentTemplateFileUrls = new Dictionary <string, string>() { { "DefaultUri", "fakeurl" } } } } })); galleryTemplatesClient.DownloadGalleryTemplateFile( galleryTemplateFileName, expectedFilePath, true, null); Assert.Equal(string.Empty, File.ReadAllText(expectedFilePath)); } finally { File.Delete(expectedFilePath); } }