private void UnsetRecommendedVersion(Package package, PublishedPackage publishedPackage) { package.IsLatestVersion = false; publishedPackage.IsLatestVersion = false; _packageRepository.Update(package); _publishedPackageRepository.Update(publishedPackage); }
private static PackagingEntry CreatePackageEntry(PublishedPackage package, PackagingSource source, Uri downloadUri) { var baseUri = new Uri(string.Format("{0}://{1}:{2}/", downloadUri.Scheme, downloadUri.Host, downloadUri.Port)); PublishedScreenshot screenshot = package.Screenshots != null?package.Screenshots.FirstOrDefault() : null; string iconUrl = GetAbsoluteUri(package.IconUrl, baseUri); string firstScreenshot = screenshot != null?GetAbsoluteUri(screenshot.ScreenshotUri, baseUri) : string.Empty; return(new PackagingEntry { Title = string.IsNullOrWhiteSpace(package.Title) ? package.Id : package.Title, PackageId = package.Id, PackageStreamUri = downloadUri.ToString(), ProjectUrl = package.ProjectUrl, GalleryDetailsUrl = package.GalleryDetailsUrl, Source = source, Version = package.Version ?? string.Empty, Description = package.Description, Authors = package.Authors, LastUpdated = package.LastUpdated, IconUrl = iconUrl, FirstScreenshot = firstScreenshot, Rating = package.Rating, RatingsCount = package.RatingsCount, DownloadCount = package.DownloadCount }); }
private void Unpublish(Package package, PublishedPackage publishedPackage) { package.Published = Constants.UnpublishedDate; publishedPackage.Published = Constants.UnpublishedDate; _packageRepository.Update(package); _publishedPackageRepository.Update(publishedPackage); }
private static void VerifyPackageIsInPublishedState(Package package, PublishedPackage publishedPackage) { if (package.Published == Constants.UnpublishedDate || publishedPackage == null || publishedPackage.Published == Constants.UnpublishedDate) { throw new InvalidOperationException("Cannot Unpublish a Package that is not currently Published."); } }
public void ShouldThrowWhenNoPackageIsGiven() { PublishedPackage nullPackage = null; TestDelegate methodThatShouldThrow = () => _creator.CreateUri(nullPackage); Assert.Throws <ArgumentNullException>(methodThatShouldThrow); }
private static PackagingEntry CreatePackagingEntry(PublishedPackage package) { return(new PackagingEntry { PackageId = package.Id, Title = package.Title, Version = package.Version, }); }
public void SetUp() { _mockedConfigSettings = new Mock <IConfigSettings>(); _creator = new Infrastructure.Impl.PackageReportAbuseUriCreator(_mockedConfigSettings.Object); _testPackage = new PublishedPackage { Id = "TestId", Version = "TestVersion" }; }
public string CreateUri(PublishedPackage package) { if (package == null) { throw new ArgumentNullException("package"); } return(_configSettings.ReportAbuseUriTemplate.Replace(PackageUriTemplateToken.PackageId, package.Id) .Replace(PackageUriTemplateToken.PackageVersion, package.Version)); }
public void IconUrlShouldBeNullWhenEmptyOrWhitespaceStringGiven(string iconUrl) { Package packageToMapFrom = new Package { IconUrl = iconUrl }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.IconUrl, "IconUrl should have been null."); }
public void CategoriesShouldBeDirectlyMapped() { Package packageToMapFrom = new Package { Categories = "Foo, Bar" }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.AreEqual(packageToMapFrom.Categories, publishedPackage.Categories, "Categories were not mapped from Package to PublishedPackage correctly."); }
public void TitleShouldBeNullWhenEmptyOrWhitespaceStringGiven(string title) { Package packageToMapFrom = new Package { Title = title }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Title, "Title should have been null."); }
public void AuthorsShouldBeNullWhenEmptyOrWhitespaceStringGiven(string authors) { Package packageToMapFrom = new Package { Authors = authors }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Authors, "Authors should have been null."); }
public void RatingsCountShouldBeMappedToVersionRatingsCount() { Package packageToMapFrom = new Package { RatingsCount = 66 }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.AreEqual(packageToMapFrom.RatingsCount, publishedPackage.VersionRatingsCount, "VersionRatingCount should come from RatingsCount."); }
public void TagsShouldBeNullWhenEmptyOrWhitespaceStringGiven(string tags) { Package packageToMapFrom = new Package { Tags = tags }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Tags, "Tags should have been null."); }
public void ShouldThrowWhenPublishedPackageWithGivenIdAndVersionDoesNotExist() { IQueryable <PublishedPackage> publishedPackages = new PublishedPackage[0].AsQueryable(); _mockedPublishedPackageRepository.SetupGet(ppr => ppr.Collection).Returns(publishedPackages); TestDelegate methodThatShouldThrow = () => _packageController.Download("Id", "Version"); Assert.Throws <PackageFileDoesNotExistException>(methodThatShouldThrow, "Exception should have been thrown."); }
public void ExternalPackageUrlShouldBeNullWhenEmptyOrWhitespaceStringGiven(string externalPackageUrl) { Package packageToMapFrom = new Package { ExternalPackageUrl = externalPackageUrl }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.ExternalPackageUrl, "ExternalPackageUrl should have been null."); }
public void PackageHashShouldBeNullWhenEmptyOrWhitespaceStringGiven(string packageHash) { Package packageToMapFrom = new Package { PackageHash = packageHash }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.PackageHash, "PackageHash should have been null."); }
public void CopyrightShouldBeNullWhenEmptyOrWhitespaceStringGiven(string copyright) { Package packageToMapFrom = new Package { Copyright = copyright }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Copyright, "Copyright should have been null."); }
public void SummaryShouldBeNullWhenEmptyOrWhitespaceStringGiven(string summary) { Package packageToMapFrom = new Package { Summary = summary }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Summary, "Summary should have been null."); }
public void DescriptionShouldBeNullWhenEmptyOrWhitespaceStringGiven(string description) { Package packageToMapFrom = new Package { Description = description }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Description, "Description should have been null."); }
public void CategoriesShouldBeNullWhenEmptyOrWhitespaceStringGiven(string categories) { Package packageToMapFrom = new Package { Categories = categories }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.IsNull(publishedPackage.Categories, "Categories should have been null."); }
public void RatingAverageShouldBeMappedToVersionRating() { Package packageToMapFrom = new Package { RatingAverage = 4.5 }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.AreEqual(packageToMapFrom.RatingAverage, publishedPackage.VersionRating, "VersionRating should come from RatingAverage."); }
public void DownloadCountOnPublishedPackageShouldBeMappedTo0WhenAggregateForPackageIdDoesNotExist() { const int expectedDownloadCount = 0; MockedPackageDataAggregateRepository.SetupGet(pdar => pdar.Collection).Returns(new PackageDataAggregate[0].AsQueryable()); PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(new Package()); Assert.AreEqual(expectedDownloadCount, publishedPackage.DownloadCount, "DownloadCount should have been mapped to 0."); }
public void ShouldSaveMappedPublishedPackage() { var publishedPackageToCreate = new PublishedPackage(); _mockedMapper.Setup(m => m.Map <Package, PublishedPackage>(_existingPackage)).Returns(publishedPackageToCreate); _packagePublisher.PublishPackage("newKey", EXISTING_PACKAGE_ID, EXISTING_PACKAGE_VERSION, LOG_ACTION); _mockedPublishedPackageRepository.Verify(ppr => ppr.Create(publishedPackageToCreate), Times.Once(), "Mapped PublishedPackage should have been created."); }
public void PackageRatingsCountShouldNotBeDirectlyMappedToRatingsCountInPublishedPackage() { Package packageToMapFrom = new Package { RatingsCount = 37 }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.AreNotEqual(packageToMapFrom.RatingsCount, publishedPackage.RatingsCount, "RatingsCount on PublishedPackage should not come from Package.RatingsCount."); }
public void ShouldCreateAPackageLogEntryForCreateWhenPackageHasNotBeenPublished() { var publishedPackageToCreate = new PublishedPackage(); _mockedMapper.Setup(m => m.Map <Package, PublishedPackage>(_existingPackage)).Returns(publishedPackageToCreate); _packagePublisher.PublishPackage("newKey", EXISTING_PACKAGE_ID, EXISTING_PACKAGE_VERSION, LOG_ACTION); _mockedPackageLogEntryCreator.Verify(c => c.Create(EXISTING_PACKAGE_ID, EXISTING_PACKAGE_VERSION, PackageLogAction.Create), Times.Once(), "PackageLogEntryCreator's Create() should have been called exactly once for a Create action with the expected package ID and version."); }
public void PackageDownloadCountShouldNotBeDirectlyMappedToDownloadCountInPublishedPackage() { Package packageToMapFrom = new Package { DownloadCount = 45 }; PublishedPackage publishedPackage = Mapper.Map <Package, PublishedPackage>(packageToMapFrom); Assert.AreNotEqual(packageToMapFrom.DownloadCount, publishedPackage.DownloadCount, "DownloadCount on PublishedPackage should not come from Package.DownloadCount."); }
protected override PublishedScreenshot GetObjectToCreate() { PublishedPackage existingPackage = PackageTestHelpers.GetExistingPublishedPackage(); return(new PublishedScreenshot { Caption = _caption, PublishedPackageId = existingPackage.Id, PublishedPackageVersion = existingPackage.Version }); }
public string CreateUri(PublishedPackage package) { if (package == null) { throw new ArgumentNullException("package"); } string packageTypeSlug = GallerySlugifyPackageType(package.PackageType); return(_configSettings.GalleryDetailsUriTemplate.Replace(PackageUriTemplateToken.PackageTypeSlug, packageTypeSlug) .Replace(PackageUriTemplateToken.PackageId, package.Id) .Replace(PackageUriTemplateToken.PackageVersion, package.Version)); }
public void ShouldNotCallLatestVersionUpdaterWhenPackageToPublishIsNotLatestVersion() { var publishedPackageToCreate = new PublishedPackage { IsLatestVersion = false }; _mockedMapper.Setup(m => m.Map <Package, PublishedPackage>(_existingPackage)).Returns(publishedPackageToCreate); _packagePublisher.PublishPackage("newKey", EXISTING_PACKAGE_ID, EXISTING_PACKAGE_VERSION, LOG_ACTION); _mockedLatestVersionUpdater.Verify(lvu => lvu.SetLatestVersionFlagsOfOtherVersionablesWithSameId(It.IsAny <PublishedPackage>()), Times.Never(), "LatestVersionUpdater should not have been called."); }
public void AddToPackages(PublishedPackage publishedPackage) { base.AddObject("Packages", publishedPackage); }
public static PublishedPackage CreatePublishedPackage(string ID, string version, long packageSize, decimal price, bool requireLicenseAcceptance, bool isLatestVersion, double versionRating, int versionRatingsCount, int versionDownloadCount, global::System.DateTime created, global::System.DateTime lastUpdated, global::System.DateTime published, double rating, int ratingsCount, int downloadCount) { PublishedPackage publishedPackage = new PublishedPackage(); publishedPackage.Id = ID; publishedPackage.Version = version; publishedPackage.PackageSize = packageSize; publishedPackage.Price = price; publishedPackage.RequireLicenseAcceptance = requireLicenseAcceptance; publishedPackage.IsLatestVersion = isLatestVersion; publishedPackage.VersionRating = versionRating; publishedPackage.VersionRatingsCount = versionRatingsCount; publishedPackage.VersionDownloadCount = versionDownloadCount; publishedPackage.Created = created; publishedPackage.LastUpdated = lastUpdated; publishedPackage.Published = published; publishedPackage.Rating = rating; publishedPackage.RatingsCount = ratingsCount; publishedPackage.DownloadCount = downloadCount; return publishedPackage; }