public static Mocks.WebRequestHandler SetupFiles(this Mocks.WebRequestHandler h, string libraryId, string githubLibraryId) { string files = @"{ ""files"": [ { ""name"": ""testFile.js"" } ] }"; return(h.ArrangeResponse(string.Format(JsDelivrCatalog.LibraryFileListUrlFormat, libraryId), files) .ArrangeResponse(string.Format(JsDelivrCatalog.LibraryFileListUrlFormatGH, githubLibraryId), files)); }
public static Mocks.WebRequestHandler SetupVersions(this Mocks.WebRequestHandler h, string libraryName) { string packageData = @"{ ""version"": ""1.0.0"" }"; return(h.ArrangeResponse(string.Format(UnpkgCatalog.LatestLibraryVersonUrl, libraryName), packageData)); }
public static Mocks.WebRequestHandler SetupVersions(this Mocks.WebRequestHandler h, string libraryId, string githubLibraryId) { string versions = @"{ ""tags"": { ""beta"": ""2.0.0-beta"", ""latest"": ""1.0.0"" } }"; return(h.ArrangeResponse(string.Format(JsDelivrCatalog.LatestLibraryVersionUrl, libraryId), versions) .ArrangeResponse(string.Format(JsDelivrCatalog.LatestLibraryVersionUrlGH, githubLibraryId), versions)); }
public static Mocks.WebRequestHandler SetupFiles(this Mocks.WebRequestHandler h, string libraryId) { string files = @"{ ""type"": ""directory"", ""files"": [ { ""path"": ""testFile.js"", ""type"": ""file"" } ] }"; (string name, string version) = new VersionedLibraryNamingScheme().GetLibraryNameAndVersion(libraryId); return(h.ArrangeResponse(string.Format(UnpkgCatalog.LibraryFileListUrlFormat, name, version), files)); }
public async Task NpmPackageSearch_GetPackageInfoAsync_ScopedPackage() { string searchItem = "@angular/cli"; var expectedVersions = (new[] { "1.0.1", "2.1.7", "3.1.4-pi" }) .Select(x => SemanticVersion.Parse(x)) .ToList(); string packageInfoRequest = "https://registry.npmjs.org/@angular%2fcli"; var requestHandler = new Mocks.WebRequestHandler(); requestHandler.ArrangeResponse(packageInfoRequest, FakeResponses.FakeLibraryWithVersions); var sut = new NpmPackageInfoFactory(requestHandler); NpmPackageInfo packageInfo = await sut.GetPackageInfoAsync(searchItem, CancellationToken.None); Assert.AreEqual("fakelibrary", packageInfo.Name); Assert.AreEqual("fake description", packageInfo.Description); CollectionAssert.AreEquivalent(expectedVersions, packageInfo.Versions.ToList()); }