public async Task GetLotsByUserAsync_GetLotsOfUser_1LotReturned()
        {
            var userProfileId = 1;

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

            var result = await _service.GetLotsByUserAsync(userProfileId, 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> GetLotsByUserAsync(int userProfileId, [FromUri] PagingModel model)
        {
            if (model == null || !ModelState.IsValid)
            {
                model = new PagingModel()
                {
                    Limit = 10, Offset = 0
                }
            }
            ;
            var(lots, totalCount) = await _lotsService.GetLotsByUserAsync(userProfileId, model.Limit, model.Offset);

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