public async Task CheckIfBaseTestPackageExistsAsync() { // Check if the BaseTestPackage exists in current source and if not upload it. // This will be used by the download related tests. try { var clientSdkHelper = new ClientSdkHelper(ConsoleTestOutputHelper.New); if (!clientSdkHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl)) { var testOutputHelper = ConsoleTestOutputHelper.New; var commandlineHelper = new CommandlineHelper(testOutputHelper); var packageCreationHelper = new PackageCreationHelper(testOutputHelper); var packageFullPath = await packageCreationHelper.CreatePackage(Constants.TestPackageId, "1.0.0"); var processResult = await commandlineHelper.UploadPackageAsync(packageFullPath, UrlHelper.V2FeedPushSourceUrl); Assert.True(processResult.ExitCode == 0, Constants.UploadFailureMessage); } } catch (Exception exception) { var message = string.Format( "The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl); throw new InvalidOperationException(message, exception); } }
public async Task FailToUnlist(ClientSdkHelper helper, string unlistApiKey = null) { if (CanUseApiKeyToUnlist(unlistApiKey)) { throw new ArgumentException($"Cannot use {unlistApiKey} to fail to unlist a package ({Id} {Version}) that was pushed by {UploadApiKey}.", nameof(unlistApiKey)); } await PackageIsReady; await helper.UnlistPackage(Id, UploadHelper.GetUniquePackageVersion(), unlistApiKey, success : false); }
public async Task<PackageInfo> PushNewVersion(ClientSdkHelper helper, string uploadApiKey = null) { if (!CanUseApiKeyToPushNewVersion(uploadApiKey)) { throw new ArgumentException($"Cannot use {uploadApiKey} to push a new version of a package ({Id} {Version}) that was pushed by {UploadApiKey}.", nameof(uploadApiKey)); } await PackageIsReady; return await CreateForUpload(Id, helper, uploadApiKey); }
public async Task DownloadPackageFromV2FeedWithOperation(string packageId, string version, string operation) { string filename = await DownloadPackageFromFeed(packageId, version, operation); // Check if the file exists. Assert.True(File.Exists(filename), Constants.PackageDownloadFailureMessage); var clientSdkHelper = new ClientSdkHelper(TestOutputHelper); 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.True(downloadedPackageId.Equals(packageId), Constants.UnableToZipError); }
private static async Task<PackageInfo> CreateForUpload(string id, ClientSdkHelper helper, string uploadApiKey = null) { var packageInfo = new PackageInfo( id, UploadHelper.GetUniquePackageVersion(), uploadApiKey); packageInfo.PackageIsReady = helper.UploadPackage(packageInfo.Id, packageInfo.Version, uploadApiKey, success: true); lock (ExistingPackagesLock) { Packages.Add(packageInfo); } await packageInfo.PackageIsReady; return packageInfo; }
public async Task Unlist(ClientSdkHelper helper, string unlistApiKey = null) { if (!CanUseApiKeyToUnlist(unlistApiKey)) { throw new ArgumentException($"Cannot use {unlistApiKey} to unlist a package ({Id} {Version}) that was pushed by {UploadApiKey}.", nameof(unlistApiKey)); } await PackageIsReady; lock (ExistingPackagesLock) { Listed = false; UnlistApiKey = unlistApiKey; PackageIsReady = helper.UnlistPackage(Id, Version, unlistApiKey, success: true); } await PackageIsReady; }
public async Task CheckIfBaseTestPackageExistsAsync() { // Check if the BaseTestPackage exists in current source and if not upload it. // This will be used by the download related tests. try { var clientSdkHelper = new ClientSdkHelper(ConsoleTestOutputHelper.New); if (!clientSdkHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl)) { await clientSdkHelper.UploadNewPackageAndVerify(Constants.TestPackageId); } } catch (Exception exception) { var message = string.Format( "The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl); throw new InvalidOperationException(message, exception); } }
public async Task CheckIfBaseTestPackageExistsAsync() { // Check if the BaseTestPackage exists in current source and if not upload it. // This will be used by the download related tests. try { var clientSdkHelper = new ClientSdkHelper(ConsoleTestOutputHelper.New); if (!clientSdkHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl)) { await clientSdkHelper.UploadNewPackageAndVerify(Constants.TestPackageId); } } catch (Exception exception) { var message = string.Format( "The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl); throw new InvalidOperationException(message, exception); } }
public async Task DownloadPackageFromV2FeedWithOperation(string packageId, string version, string operation) { string filename = await DownloadPackageFromFeed(packageId, version, operation); // Check if the file exists. Assert.True(File.Exists(filename), Constants.PackageDownloadFailureMessage); var clientSdkHelper = new ClientSdkHelper(TestOutputHelper); 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.True(downloadedPackageId.Equals(packageId), Constants.UnableToZipError); }
public static Task <PackageInfo> CreateForUpload(ClientSdkHelper helper, string uploadApiKey = null) { return(CreateForUpload(UploadHelper.GetUniquePackageId(), helper, uploadApiKey)); }
public void Dispose() { // Clear the machine cache during the end of every test to make sure that we always hit the gallery. ClientSdkHelper.ClearMachineCache(); }
public ClearMachineCacheFixture() { // Clear the machine cache during the start of every test to make sure that we always hit the gallery. ClientSdkHelper.ClearMachineCache(); }