Ejemplo n.º 1
0
        public async Task <ActionResult> Find(
            [FromQuery] string title,
            [FromQuery] string author,
            [FromQuery] string publisher,
            [FromQuery] string subject,
            [FromQuery] string volumeId,
            [FromQuery] int maxResults,
            [FromQuery] int startIndex,
            [FromQuery] PrintType printType,
            [FromQuery] Projection projection,
            [FromQuery] Sorting orderBy)
        {
            _queryBuilder
            .SetTitle(title)
            .SetAuthor(author)
            .SetPublisher(publisher)
            .SetSubject(subject)
            .SetVolumeId(volumeId)
            .SetMaxResults(maxResults)
            .SetProjection(projection)
            .SetStartIndex(startIndex)
            .SetPrintType(printType)
            .SetOrderBy(orderBy);

            return(Ok(await _bookRepository.FindByFilter(_queryBuilder)));
        }
Ejemplo n.º 2
0
        public void ShouldCreateQueryOk()
        {
            _builder.SetTitle(_title)
            .SetAuthor(_author)
            .SetPublisher(_publisher)
            .SetSubject(_subject)
            .SetVolumeId(_volumeId)
            .SetMaxResults(_maxResults)
            .SetProjection(_projection)
            .SetStartIndex(_startIndex)
            .SetPrintType(_printType)
            .SetOrderBy(_orderBy);

            var query = _builder.BuildQueryString();

            Assert.AreEqual(10, query.Split('&').Length);

            StringAssert.Contains($"{Parameters.Intitle}:{_title}", query);
            StringAssert.Contains($"{Parameters.Inauthor}:{_author}", query);
            StringAssert.Contains($"{Parameters.InPublisher}:{_publisher}", query);
            StringAssert.Contains($"{Parameters.Subject}:{_subject}", query);
            StringAssert.Contains($"{Parameters.VolumeId}:{_volumeId}", query);
            StringAssert.Contains($"{Parameters.MaxResults}={_maxResults}", query);
            StringAssert.Contains($"{Parameters.Projection}={_projection.Description()}", query);
            StringAssert.Contains($"{Parameters.StartIndex}={_startIndex}", query);
            StringAssert.Contains($"{Parameters.PrintType}={_printType.Description()}", query);
            StringAssert.Contains($"{Parameters.OrderBy}={_orderBy.Description()}", query);
        }