public void WhenGetItemsToBuy_PaymentSuccessfulForAvailableItemsInStock_ReturnsItemCount() { _mockdiscountService.Setup(x => x.GetApplyDiscount(It.IsAny <Int16>(), It.IsAny <double>())).Returns(It.IsAny <double>()); _mockPaymentRepo.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK))); _mocklogger.Setup(x => x.write(It.IsAny <string>())); var result = _shoppingService.GetItemsToBuy(items); Assert.AreEqual(2, result); }
static void Main(string[] args) { Console.WriteLine("Enter Customer Id"); int customerId = Int32.Parse(Console.ReadLine()); while (customerId.ToString() == null) { Console.WriteLine("Enter Customer Id"); customerId = Int32.Parse(Console.ReadLine()); } var stockService = new StockService(new StockRepository()); var discountService = new DiscountService(new DiscountRepository()); var paymentGateway = new PaymentRepository(new PaymentGatewayClient(new System.Net.Http.HttpClient())); List <string> items = new List <string>() { "Breads", "Milk", "Biscuits", "DryFruits" }; ShoppingService shopping = new ShoppingService(customerId, stockService, discountService, paymentGateway, new Logger()); var count = shopping.GetItemsToBuy(items); var resutl = count > 0 ? $"Shopping done for {count} products" : $"Shopping done for {count} products"; Console.WriteLine(resutl); Console.ReadLine(); }