public async Task SearchProductByTextAsync_ShouldReturnSearchResultForSearchTex() { var searchItem = new ItemSearch { query = "ipod", items = new Item[] { new Item { itemId = "42608125" } } }; var searchProduct = new ProductSearch { queryTime = 3.2, products = new Product[] { new Product { productId = "1219661412848" } } }; var searchText = "ipod"; var mock = new Mock <IWalmartServiceContext>(); var bbmock = new Mock <IBestbuyServiceContext>(); mock.Setup(m => m.SearchItemByTextAsync(searchText)).Returns(Task.FromResult(searchItem)); xStoreRepository = new XStoreRepository(mock.Object, bbmock.Object); var result = await xStoreRepository.SearchProductByTextAsync(searchText); Assert.AreEqual(result.SearchTerm, searchText); mock.VerifyAll(); }
public async Task GetProductByProductIdAsync_ShouldReturnProductForGivenProductId() { var items = new Item[] { new Item { itemId = "12417832" } }; var itemId = "12417832"; var products = new Product[] { new Product { productId = "1219661412848" } }; var productId = "1219661412848"; var mock = new Mock <IWalmartServiceContext>(); var bbmock = new Mock <IBestbuyServiceContext>(); mock.Setup(m => m.GetItemByItemIdAsync(itemId)).Returns(Task.FromResult(items.ToList())); xStoreRepository = new XStoreRepository(mock.Object, bbmock.Object); var result = await xStoreRepository.GetProductByProductIdAsync(itemId); Assert.AreEqual(result[0].ProductId, itemId); }
public async Task SearchProductByTextAsync_ShouldReturnSearchResultForSearchTex() { var searchItem = new ItemSearch { query = "ipod", items = new Item[] { new Item { itemId = "42608125" } } }; var searchText = "ipod"; var mock = new Mock <IWalmartServiceContext>(); mock.Setup(m => m.SearchItemByTextAsync(searchText)).Returns(Task.FromResult(searchItem)); walmartRepository = new WalmartRepository(mock.Object); var result = await walmartRepository.SearchProductByTextAsync(searchText); Assert.AreEqual(result.SearchTerm, searchText); mock.VerifyAll(); }
public async Task GetRecommendationsByProeuctIddAsync_ShouldReturnRecommendationsForProduct() { var recommendations = new List <ItemRecommendation>() { new ItemRecommendation { itemId = "42608125", name = "Onn by Walmart skin for apple ipod touch", offerType = "ONLINE_AND_STORE" } }; var recommendItemId = "12417832"; var mock = new Mock <IWalmartServiceContext>(); mock.Setup(m => m.GetItemRecommendationByItemIdAsync(recommendItemId)).Returns(Task.FromResult(recommendations)); walmartRepository = new WalmartRepository(mock.Object); var result = await walmartRepository.GetRecommendationsByProeuctIddAsync(recommendItemId); Assert.AreEqual(result[0].ProductId, "42608125"); Assert.AreEqual(result[0].Product.ProductName, "Onn by Walmart skin for apple ipod touch"); mock.VerifyAll(); }
public ProductService(IRepositoryRest walmartRepository) { this.walmartRepository = walmartRepository; }
public ProductService(IRepositoryRest xStoreRepository) { this.xStoreRepository = xStoreRepository; }