コード例 #1
0
ファイル: ApiIntegrationTests.cs プロジェクト: sipmann/BaGet
        public async Task SearchReturnsOk()
        {
            await _factory.AddPackageAsync(_packageStream);

            using var response = await _client.GetAsync("v3/search");

            var content = await response.Content.ReadAsStreamAsync();

            var json = PrettifyJson(content);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(@"{
  ""@context"": {
    ""@vocab"": ""http://schema.nuget.org/schema#"",
    ""@base"": ""http://localhost/v3/registration""
  },
  ""totalHits"": 1,
  ""data"": [
    {
      ""id"": ""TestData"",
      ""version"": ""1.2.3"",
      ""description"": ""Test description"",
      ""authors"": [
        ""Test author""
      ],
      ""iconUrl"": """",
      ""licenseUrl"": """",
      ""projectUrl"": """",
      ""registration"": ""http://localhost/v3/registration/testdata/index.json"",
      ""summary"": """",
      ""tags"": [],
      ""title"": """",
      ""totalDownloads"": 0,
      ""versions"": [
        {
          ""@id"": ""http://localhost/v3/registration/testdata/1.2.3.json"",
          ""version"": ""1.2.3"",
          ""downloads"": 0
        }
      ]
    }
  ]
}", json);
        }
コード例 #2
0
        public async Task SearchReturnsResults()
        {
            await _factory.AddPackageAsync(_packageStream);

            var resource = await _repository.GetResourceAsync <PackageSearchResource>();

            var searchFilter = new SearchFilter(includePrerelease: true);

            var results = await resource.SearchAsync(
                "",
                searchFilter,
                skip : 0,
                take : 20,
                _logger,
                _cancellationToken);

            var result = Assert.Single(results);

            Assert.Equal("TestData", result.Identity.Id);
            Assert.Equal("1.2.3", result.Identity.Version.ToNormalizedString());
            Assert.Equal("Test description", result.Description);
            Assert.Equal("Test author", result.Authors);
            Assert.Equal(0, result.DownloadCount);

            var versions = await result.GetVersionsAsync();

            var version = Assert.Single(versions);

            Assert.Equal("1.2.3", version.Version.ToNormalizedString());
            Assert.Equal(0, version.DownloadCount);
        }
コード例 #3
0
        public async Task SearchReturnsResults()
        {
            await _factory.AddPackageAsync(_packageStream);

            var results = await _client.SearchAsync();

            var result  = Assert.Single(results);
            var author  = Assert.Single(result.Authors);
            var version = Assert.Single(result.Versions);

            Assert.Equal("TestData", result.PackageId);
            Assert.Equal("1.2.3", result.Version);
            Assert.Equal("Test description", result.Description);
            Assert.Equal("Test author", author);
            Assert.Equal(0, result.TotalDownloads);

            Assert.Equal("1.2.3", version.Version);
            Assert.Equal(0, version.Downloads);
        }