public void AddItems() { userBasketRepo.Setup(x => x.AddRange(It.IsAny <List <IUserBasketItem> >())) .Returns(() => { return(new List <IUserBasketItem> { new UserBasketItem { ItemId = 1, UserId = USER_ID } }); }); basketItemRepo.Setup(x => x.Exists(It.IsAny <Func <IBasketItem, bool> >())) .Returns(true); var service = new ShoppingBasketService(userBasketRepo.Object, basketItemRepo.Object, discountRepo.Object); var newItem = new AddItemModel(1, 1); var hasAddedItem = service.Add(newItem, USER_ID); Assert.IsTrue(hasAddedItem); }
public void AddItemsThrowsShoppingBasketException() { basketItemRepo.Setup(b => b.Exists(It.IsAny <Func <IBasketItem, bool> >())) .Returns(false); var service = new ShoppingBasketService(userBasketRepo.Object, basketItemRepo.Object, discountRepo.Object); var newItem = new AddItemModel(1, 1); Assert.Throws <ShoppingBasketException>(delegate { service.Add(newItem, USER_ID); }); }
public void AddItemsThrowsArgumentNullException() { var service = new ShoppingBasketService(userBasketRepo.Object, basketItemRepo.Object, discountRepo.Object); Assert.Throws <ArgumentNullException>(delegate { service.Add(null, USER_ID); }); }