public static void DownloadPackageFromV2FeedWithOperation(string packageId, string version, string operation) { try { Task <string> downloadTask = ODataHelper.DownloadPackageFromFeed(packageId, version, operation); string filename = downloadTask.Result; //check if the file exists. Assert.IsTrue(File.Exists(filename), Constants.PackageDownloadFailureMessage); string downloadedPackageId = ClientSDKHelper.GetPackageIdFromNupkgFile(filename); //Check that the downloaded Nupkg file is not corrupt and it indeed corresponds to the package which we were trying to download. Assert.IsTrue(downloadedPackageId.Equals(packageId), Constants.UnableToZipError); } catch (Exception e) { Assert.Fail(e.Message); } }
/// <summary> /// Given a package checks if it that version of the package is installed. /// </summary> /// <param name="packageId"></param> /// <returns></returns> public static bool CheckIfPackageVersionInstalled(string packageId, string packageVersion) { //string packageVersion = ClientSDKHelper.GetLatestStableVersion(packageId); string expectedDownloadedNupkgFileName = packageId + "." + packageVersion; //check if the nupkg file exists on the expected path post install string expectedNupkgFilePath = Path.Combine(Environment.CurrentDirectory, expectedDownloadedNupkgFileName, expectedDownloadedNupkgFileName + ".nupkg"); Console.WriteLine("The expected Nupkg file path after package install is: " + expectedNupkgFilePath); if ((!File.Exists(expectedNupkgFilePath))) { Console.WriteLine(" Package file {0} not present after download", expectedDownloadedNupkgFileName); return false; } string downloadedPackageId = ClientSDKHelper.GetPackageIdFromNupkgFile(expectedNupkgFilePath); //Check that the downloaded Nupkg file is not corrupt and it indeed corresponds to the package which we were trying to download. if (!(downloadedPackageId.Equals(packageId))) { Console.WriteLine("Unable to unzip the package downloaded via Nuget Core. Check log for details"); return false; } return true; }