public async Task Get_ShouldReturnListOfBrands() { // Arrange var userId = Guid.NewGuid(); var model = new BrandQueryViewModel { UserId = userId }; var buyerAccount = new BuyerAccount { BuyerAccountId = 1 }; var advertiser = new Advertiser { BuyerAccountId = buyerAccount.BuyerAccountId, BuyerAccount = buyerAccount, AdvertiserId = 1 }; var advertiserProduct1 = new AdvertiserProduct { AdvertiserId = advertiser.AdvertiserId, ProductName = "product a" }; var advertiserProduct2 = new AdvertiserProduct { AdvertiserId = advertiser.AdvertiserId, ProductName = "product b" }; var advertiserProducts = new List <AdvertiserProduct> { advertiserProduct1, advertiserProduct2 }; Mock.Mock <IBrandService>().Setup(x => x.GetBrands(It.IsAny <BrandQueryOptions>())) .Returns(advertiserProducts.ToAsyncEnumerable()); // Act var retVal = await Controller.Get(model); // Assert Assert.That(retVal, Is.Not.Null); Assert.That(retVal.TotalItemCount, Is.EqualTo(2)); }
public async Task <PagedListViewModel <BrandListViewModel> > Get([FromUri] BrandQueryViewModel model) { var brandQueryOptions = _mapping.Map <BrandQueryOptions>(model); var brands = await _brandService.GetBrands(brandQueryOptions).ToPagedListAsync(model).ConfigureAwait(false); return(_mapping.Map <PagedListViewModel <BrandListViewModel> >(brands)); }