Ejemplo n.º 1
0
        public override int Execute()
        {
            var isDetailed = _parseResult.GetValueForOption(ToolSearchCommandParser.DetailOption);
            NugetSearchApiParameter nugetSearchApiParameter = new NugetSearchApiParameter(_parseResult);
            IReadOnlyCollection <SearchResultPackage> searchResultPackages =
                NugetSearchApiResultDeserializer.Deserialize(
                    _nugetToolSearchApiRequest.GetResult(nugetSearchApiParameter).GetAwaiter().GetResult());

            _searchResultPrinter.Print(isDetailed, searchResultPackages);

            return(0);
        }
Ejemplo n.º 2
0
        public override int Execute()
        {
            var isDetailed = _options.ValueOrDefault <bool>("detail");
            NugetSearchApiParameter nugetSearchApiParameter = new NugetSearchApiParameter(_options);
            IReadOnlyCollection <SearchResultPackage> searchResultPackages =
                NugetSearchApiResultDeserializer.Deserialize(
                    _nugetToolSearchApiRequest.GetResult(nugetSearchApiParameter).GetAwaiter().GetResult());

            _searchResultPrinter.Print(isDetailed, searchResultPackages);

            return(0);
        }
        public void ItCanDeserialize()
        {
            var json = File.ReadAllText("queryResultSample.json");

            var result = NugetSearchApiResultDeserializer.Deserialize(json);

            var firstItem = result.First();

            firstItem.Authors.Should().ContainSingle("author is a scalar");
            firstItem.Description.Should().Be("test app");
            firstItem.Id.Should().Be(new PackageId("global.tool.console.demo"));
            firstItem.LatestVersion.Should().Be("1.0.4");
            firstItem.Summary.Should().Be("The summary");
            firstItem.Tags.Should().ContainSingle("test");
            firstItem.TotalDownloads.Should().Be(20);
            firstItem.Verified.Should().BeFalse();
            firstItem.Versions.Single().Downloads.Should().Be(20);
            firstItem.Versions.Single().Version.Should().Be("1.0.4");

            var secondItem = result.Skip(1).First();

            secondItem.Authors.Should().ContainInOrder("author1", "authors2");
        }