private static void PopulateDownloadCount <T>( T document, long totalDownloadCount) where T : KeyedDocument, SearchDocument.IDownloadCount { document.TotalDownloadCount = totalDownloadCount; document.DownloadScore = DocumentUtilities.GetDownloadScore(totalDownloadCount); }
public void EncodesSearchDocumentKey(string id, string expected) { foreach (var searchFilters in Enum.GetValues(typeof(SearchFilters)).Cast <SearchFilters>()) { var actual = DocumentUtilities.GetSearchDocumentKey(id, searchFilters); Assert.Equal(expected + "-" + searchFilters, actual); } }
public void IsCompatibleWithHttpServerUtilityUrlTokenEncode() { var random = new Random(0); for (var i = 0; i < 1_000_000; i++) { var bytes = new byte[random.Next(0, 8) + 1]; random.NextBytes(bytes); var expected = HttpServerUtility.UrlTokenEncode(bytes); var actual = DocumentUtilities.Base64UrlEncode(bytes); Assert.Equal(expected, actual); } }
private void PopulateUpdateLatest( SearchDocument.UpdateLatest document, string packageId, SearchFilters searchFilters, bool lastUpdatedFromCatalog, DateTimeOffset?lastCommitTimestamp, string lastCommitId, string[] versions, bool isLatestStable, bool isLatest, string fullVersion, string[] owners, string[] packageTypes) { PopulateVersions( document, packageId, searchFilters, lastUpdatedFromCatalog, lastCommitTimestamp, lastCommitId, versions, isLatestStable, isLatest); document.SearchFilters = DocumentUtilities.GetSearchFilterString(searchFilters); document.FullVersion = fullVersion; // If the package has explicit types, we will set them here. // Otherwise, we will treat the package as a "Depedency" type and fill in the explicit type. if (packageTypes != null && packageTypes.Length > 0) { document.PackageTypes = packageTypes; document.FilterablePackageTypes = packageTypes.Select(pt => pt.ToLowerInvariant()).ToArray(); } else { document.PackageTypes = ImpliedDependency; document.FilterablePackageTypes = FilterableImpliedDependency; } PopulateOwners( document, owners); }
public void EncodesHijackDocumentKey(string id, string version, string expected) { var actual = DocumentUtilities.GetHijackDocumentKey(id, version); Assert.Equal(expected, actual); }
private static void PopulateKey(KeyedDocument document, string packageId, string normalizedVersion) { document.Key = DocumentUtilities.GetHijackDocumentKey(packageId, normalizedVersion); }
private static void PopulateKey(KeyedDocument document, string packageId, SearchFilters searchFilters) { document.Key = DocumentUtilities.GetSearchDocumentKey(packageId, searchFilters); }