コード例 #1
0
        public void Should_Get_Artifacts_When_results_exist()
        {
            _artifactDao.CountArtifact(Arg.Any <ArtifactCriteria>()).ReturnsForAnyArgs(50);
            _artifactDao.GetArtifacts(Arg.Any <ArtifactCriteria>())
            .ReturnsForAnyArgs(_fixture.CreateMany <Artifact>(50));

            var criteria = new ArtifactCriteriaModel
            {
                Page     = 1,
                PageSize = 20
            };

            var results = _artifactRepo.GetArtifacts(criteria).Result;

            results.Results.Should().NotBeEmpty();
            results.Results.Count().Should().Be(20);
        }
コード例 #2
0
        public async Task <ArtifactResponseModel> GetArtifacts(ArtifactCriteriaModel criteriaModel)
        {
            var artifactCriteria = _modelFactory.CreateArtifactCrtieria(criteriaModel);
            var resultCount      = await _artifactDao.CountArtifact(artifactCriteria).ConfigureAwait(false);

            var artifactResponse = new ArtifactResponse
            {
                Links   = CreateLinks(artifactCriteria.Page, artifactCriteria.PageSize, resultCount),
                Results = await CreateResults(artifactCriteria, resultCount).ConfigureAwait(false)
            };

            return(_modelFactory.CreateArtifactResponseModel(artifactResponse));
        }