public void ReportingService_GetBestseller_RerurnedProduct() { // Act var products = productRepository.GetAllProducts(); vendingService.Load(products); vendingService.ChooseProduct(1); vendingService.DepositMoney(10m); vendingService.ChooseProduct(2); vendingService.DepositMoney(10m); vendingService.ChooseProduct(2); vendingService.DepositMoney(10m); vendingService.ChooseProduct(3); vendingService.DepositMoney(10m); vendingService.ChooseProduct(1); vendingService.DepositMoney(10m); vendingService.ChooseProduct(1); vendingService.DepositMoney(10m); var bestseller = reportingService.GetBestsellerProduct(); // Assert Assert.IsNotNull(bestseller); Assert.AreEqual(1, bestseller.Id); Assert.AreEqual(1.99m, bestseller.Price); }
public void VendingService_ChooseProduct_ProductChoosed() { // Assert var products = productRepository.GetAllProducts(); var result = vendingService.Load(products); // Act var output = vendingService.ChooseProduct(1); // Assert Assert.AreEqual(true, result); Assert.IsNotNull(output); Assert.AreEqual(0, output.ProductIdInTray); Assert.AreEqual(0, output.Change); }
public static void Main(string[] args) { // Get all products from repository. Should be 50 var products = productRepository.GetAllProducts(); Console.WriteLine("All products count: " + products.Count); // Initiallize beverage vending machine with products var result = vendingService.Load(products); Console.WriteLine("Loaded products: " + result); // Load additional products (one existing type and one new type) var addProducts = productRepository.GetAdditionalProducts(); Console.WriteLine("All additional products count: " + addProducts.Count); var loadAdditional = vendingService.Load(addProducts); Console.WriteLine("Loaded additional products: " + loadAdditional); // Customer choose product #1 var output1 = vendingService.ChooseProduct(1); // Output should be: Message = "Product #1 choosed. Cash inserted: 0, cash to add: 1.99" Console.WriteLine("Message: " + output1.Message); // Customer choose product #1 once again var output2 = vendingService.ChooseProduct(1); // Output should be: Message = "Product already choosed. Please complete purchase process" Console.WriteLine("Message: " + output2.Message); // Deposit cash $1 var output3 = vendingService.DepositMoney(1); // Output should be: Message = "Product #1 choosed. Cash inserted: 1, cash to add: 0.99" Console.WriteLine("Message: " + output3.Message); // Deposit cash $1 once again var output4 = vendingService.DepositMoney(1); // Output should be: Message = "Your product in the tray. Thanks" Console.WriteLine("Message: " + output4.Message); Console.WriteLine("ProductId in tray: " + output4.ProductIdInTray); Console.WriteLine("Change: " + output4.Change); vendingService.ChooseProduct(2); vendingService.DepositMoney(5); vendingService.ChooseProduct(1); vendingService.DepositMoney(10); // Report methods var reporting = GetReportingService(); // Get bestseller product. Should be #1 var bestseller = reporting.GetBestsellerProduct(); Console.WriteLine("Bestseller: #" + bestseller.Id + ", Name: " + bestseller.Name); // Get bestseller product. Should be #1 var badtseller = reporting.GetBadSellingProduct(); Console.WriteLine("Badseller: #" + badtseller.Id + ", Name: " + badtseller.Name); // Get product purchased count for today. Should be 2 items var count = reporting.GetPurchasesCount(1, DateTime.Now); Console.WriteLine("Count: " + count); Console.ReadLine(); }