public async Task FindLotsAsync_FindLots_LotReturned()
        {
            var keywords = "Lot 1";

            _mockUnitWork.Setup(x => x.Lots.FindAsync(It.IsAny <Expression <Func <Lot, bool> > >(), 10, 0))
            .ReturnsAsync((Items: _lots.Where(x => x.Name.Contains(keywords)), TotalCount: _lots.Count));

            var result = await _service.FindLotsAsync(keywords, 10, 0);

            Assert.That(result.Lots, Is.Not.Null);
            Assert.That(result.Lots.Count(), Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> GetLotsAsync([FromUri] PagingModel model, string query = null)
        {
            if (model == null || !ModelState.IsValid)
            {
                model = new PagingModel()
                {
                    Limit = 10, Offset = 0
                }
            }
            ;
            var(lots, totalCount) = query == null
                ? await _lotsService.GetAllLotsAsync(model.Limit, model.Offset)
                : await _lotsService.FindLotsAsync(query, model.Limit, model.Offset);

            if (!lots.Any())
            {
                return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.NoContent)));
            }
            return(Ok(new { lots, totalCount }));
        }