Example #1
0
        public async Task GetBidsByUserAsyncTest_GetBidsByExistingUserId_3BidsReturned()
        {
            var userProfileId = 2;

            _mockUnitWork.Setup(x => x.Bids.GetAllByUserAsync(userProfileId)).ReturnsAsync(_bids.Where(x => x.PlacedUserId == userProfileId));
            _mockUnitWork.Setup(x => x.UserProfiles.GetAsync(userProfileId)).ReturnsAsync(_users.Find(x => x.UserProfileId == userProfileId));

            var results = await _service.GetBidsByUserAsync(userProfileId);

            Assert.That(results, Is.Not.Null);
            Assert.That(results.Count(), Is.EqualTo(3));
        }
        public async Task <IHttpActionResult> GetBidsAsync(int userProfileId)
        {
            var bids = await _bidsService.GetBidsByUserAsync(userProfileId);

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