protected static Mock <TestPackageReader> GeneratePackageWithUserContent( string version = "1.2.3-alpha.0", RepositoryMetadata repositoryMetadata = null, bool isSigned = true, int?desiredTotalEntryCount = null, Func <string> getCustomNuspecNodes = null, Uri iconUrl = null, Uri licenseUrl = null, string licenseExpression = null, string licenseFilename = null, string licenseFileContents = null, byte[] licenseFileBinaryContents = null, string iconFilename = null, byte[] iconFileBinaryContents = null, string readmeFilename = null, string readmeFileContents = null, byte[] readmeFileBinaryContents = null, IReadOnlyList <string> entryNames = null) { var packageStream = GeneratePackageStream( version: version, repositoryMetadata: repositoryMetadata, isSigned: isSigned, desiredTotalEntryCount: desiredTotalEntryCount, getCustomNuspecNodes: getCustomNuspecNodes, iconUrl: iconUrl, licenseUrl: licenseUrl, licenseExpression: licenseExpression, licenseFilename: licenseFilename, licenseFileContents: licenseFileContents, licenseFileBinaryContents: licenseFileBinaryContents, iconFilename: iconFilename, iconFileBinaryContents: iconFileBinaryContents, readmeFilename: readmeFilename, readmeFileContents: readmeFileContents, readmeFileBinaryContents: readmeFileBinaryContents, entryNames: entryNames); return(PackageServiceUtility.CreateNuGetPackage(packageStream)); }
public async Task WillCallCreatePackageAsyncCorrectly() { var key = 0; var packageService = new Mock <IPackageService>(); packageService.Setup(x => x.FindPackageRegistrationById(It.IsAny <string>())).Returns((PackageRegistration)null); var id = "Microsoft.Aspnet.Mvc"; var packageUploadService = CreateService(packageService); var nugetPackage = PackageServiceUtility.CreateNuGetPackage(id: id); var owner = new User { Key = key++, Username = "******" }; var currentUser = new User { Key = key++, Username = "******" }; var package = await packageUploadService.GeneratePackageAsync(id, nugetPackage.Object, new PackageStreamMetadata(), owner, currentUser); packageService.Verify(x => x.CreatePackageAsync(It.IsAny <PackageArchiveReader>(), It.IsAny <PackageStreamMetadata>(), owner, currentUser, false), Times.Once); Assert.False(package.PackageRegistration.IsVerified); }
private Mock <TestPackageReader> GeneratePackage(IReadOnlyList <string> entryNames) { var packageStream = PackageServiceUtility.CreateNuGetPackageStream(entryNames: entryNames); return(PackageServiceUtility.CreateNuGetPackage(packageStream)); }