public async Task EndToEndTestAsync()
        {
            IProvider       provider = _dependencies.GetProvider("cdnjs");
            ILibraryCatalog catalog  = provider.GetCatalog();

            // Search for libraries to display in search result
            IReadOnlyList <ILibraryGroup> groups = await catalog.SearchAsync("jquery", 4, CancellationToken.None);

            Assert.AreEqual(4, groups.Count);

            // Show details for selected library
            ILibraryGroup group = groups.FirstOrDefault();

            Assert.AreEqual("jquery", group.DisplayName);
            Assert.IsNotNull(group.Description);

            // Get all libraries in group to display version list
            IEnumerable <string> libraryIds = await group.GetLibraryIdsAsync(CancellationToken.None);

            Assert.IsTrue(libraryIds.Count() >= 67);
            Assert.AreEqual("[email protected]", libraryIds.Last(), "Library version mismatch");

            // Get the library to install
            ILibrary library = await catalog.GetLibraryAsync(libraryIds.First(), CancellationToken.None);

            Assert.AreEqual(group.DisplayName, library.Name);

            var desiredState = new LibraryInstallationState
            {
                LibraryId       = "[email protected]",
                ProviderId      = "cdnjs",
                DestinationPath = "lib",
                Files           = new[] { "jquery.js", "jquery.min.js" }
            };

            // Install library
            ILibraryInstallationResult result = await provider.InstallAsync(desiredState, CancellationToken.None).ConfigureAwait(false);

            foreach (string file in desiredState.Files)
            {
                string absolute = Path.Combine(_projectFolder, desiredState.DestinationPath, file);
                Assert.IsTrue(File.Exists(absolute));
            }

            Assert.IsTrue(result.Success);
            Assert.IsFalse(result.Cancelled);
            Assert.AreSame(desiredState, result.InstallationState);
            Assert.AreEqual(0, result.Errors.Count);
        }
示例#2
0
        public async Task InstallAsync_FullEndToEnd()
        {
            ILibraryCatalog catalog = _provider.GetCatalog();

            // Search for libraries to display in search result
            IReadOnlyList <ILibraryGroup> groups = await catalog.SearchAsync("jquery", 4, CancellationToken.None);

            Assert.IsTrue(groups.Count > 0);

            // Show details for selected library
            ILibraryGroup group = groups.FirstOrDefault();

            Assert.AreEqual("jquery", group.DisplayName);

            // Get all libraries in group to display version list
            IEnumerable <string> libraryVersions = await group.GetLibraryVersions(CancellationToken.None);

            Assert.IsTrue(libraryVersions.Count() >= 0);

            // Get the library to install
            ILibrary library = await catalog.GetLibraryAsync(group.DisplayName, libraryVersions.First(), CancellationToken.None);

            Assert.AreEqual(group.DisplayName, library.Name);

            var desiredState = new LibraryInstallationState
            {
                Name            = "jquery",
                Version         = "3.3.1",
                ProviderId      = "unpkg",
                DestinationPath = "lib",
                Files           = new[] { "dist/jquery.js", "dist/jquery.min.js" }
            };

            // Install library
            ILibraryOperationResult result = await _provider.InstallAsync(desiredState, CancellationToken.None).ConfigureAwait(false);

            foreach (string file in desiredState.Files)
            {
                string absolute = Path.Combine(_projectFolder, desiredState.DestinationPath, file);
                Assert.IsTrue(File.Exists(absolute));
            }

            Assert.IsTrue(result.Success);
            Assert.IsFalse(result.Cancelled);
            Assert.AreSame(desiredState, result.InstallationState);
            Assert.AreEqual(0, result.Errors.Count);
        }
 public LibraryGroupToSearchItemAdapter(ILibraryGroup source)
 {
     _source = source;
 }