public SubMenu(IVendingMachineService vendingMachineService, ICampaignService campaignService, IPurchaseService purchaseService, IProductService productService) { _vendingMachineService = vendingMachineService; _campaignService = campaignService; _purchaseService = purchaseService; _productService = productService; //_serviceFactory = serviceFactory; }
private void DisplayProducts(IVendingMachineService vendingMachineService) { foreach (var vendingMachineItem in vendingMachineService.GetProductMap()) { Console.WriteLine(vendingMachineItem.Value.TotalItem > 0 ? $"{vendingMachineItem.Key} {vendingMachineItem.Value.ProductName} ({vendingMachineItem.Value.TotalItem}): ${vendingMachineItem.Value.Price}" : $"{vendingMachineItem.Key} {vendingMachineItem.Value.ProductName} ({vendingMachineItem.Value.TotalItem}): ${vendingMachineItem.Value.Price}: is out of stock."); } }
public PaymentService(IPurseRepository purseRepository, IUserDepositRepository userDepositRepository, ICustomerProductRepository customerProductRepository, IVendingMachineService vendingMachineService) { _purseRepository = purseRepository; _userDepositRepository = userDepositRepository; _customerProductRepository = customerProductRepository; _vendingMachineService = vendingMachineService; }
public static void InsertCoins( this IVendingMachineService service, CoinType coinType, int numberOfCoins ) { for (var i = 0; i < numberOfCoins; i++) { service.InsertCoinAsync(coinType.ToDecimal()); } }
public void Purchase(string[] commandArgs, IVendingMachineService vendingMachineService) { decimal.TryParse(commandArgs[1], out var priceOut); int.TryParse(commandArgs[2], out var orderNumberOut); int.TryParse(commandArgs[3], out var quantityOut); if (vendingMachineService.Purchase(orderNumberOut, quantityOut, priceOut)) { Console.WriteLine("Your order is successful enjoy!!"); Console.WriteLine(); Console.WriteLine("Thank You!!"); Console.WriteLine(); } }
public static void InsertCoinsFromTestInput( this IVendingMachineService service, WalletDto wallet) { if (wallet.OneEuroCoinAmount > 0) { service.InsertCoins(CoinType.OneEuro, wallet.OneEuroCoinAmount); } if (wallet.FiftyCentCoinAmount > 0) { service.InsertCoins(CoinType.FiftyCent, wallet.FiftyCentCoinAmount); } if (wallet.TwentyCentCoinAmount > 0) { service.InsertCoins(CoinType.TwentyCent, wallet.TwentyCentCoinAmount); } if (wallet.TenCentCoinAmount > 0) { service.InsertCoins(CoinType.TenCent, wallet.TenCentCoinAmount); } }
public void BuyProduct_SomeCoinsAreEmpty_ShouldReturn_OtherCoinChanges( decimal deposit, string productName, decimal expectedReturnVal, int initialOneEuroAmount, int initialFiftyCentAmount, int initialTwentyCentAmount, int initialTenCentAmount, int expectedOneEuroCoinAmount, int expectedFiftyCentCoinAmount, int expectedTwentyCentCoinAmount, int expectedTenCentCoinAmount ) { // arrange _walletFactory = new WalletFactory( initialOneEuroAmount, initialFiftyCentAmount, initialTwentyCentAmount, initialTenCentAmount ); _vendingMachineService = new VendingMachineService(_walletFactory); _vendingMachineService.InsertCoinsFromTestInput(deposit.ToWalletDto()); // action var result = _vendingMachineService.BuyProductAsync(productName).Result; // assert Assert.That(result, Is.Not.Null); Assert.That(result.IsSuccess, Is.True); Assert.That(result.Wallet, Is.Not.Null); Assert.That(result.Wallet.TotalValue, Is.EqualTo(expectedReturnVal)); Assert.That(result.Wallet.OneEuroCoinAmount, Is.EqualTo(expectedOneEuroCoinAmount)); Assert.That(result.Wallet.FiftyCentCoinAmount, Is.EqualTo(expectedFiftyCentCoinAmount)); Assert.That(result.Wallet.TwentyCentCoinAmount, Is.EqualTo(expectedTwentyCentCoinAmount)); Assert.That(result.Wallet.TenCentCoinAmount, Is.EqualTo(expectedTenCentCoinAmount)); }
public void BuyProduct_NoCoinChangeAvailable_ShouldRevertOrder( decimal deposit, string productName, int initialOneEuroAmount, int initialFiftyCentAmount, int initialTwentyCentAmount, int initialTenCentAmount, int expectedOneEuroCoinAmount, int expectedFiftyCentCoinAmount, int expectedTwentyCentCoinAmount, int expectedTenCentCoinAmount) { // arrange _walletFactory = new WalletFactory( initialOneEuroAmount, initialFiftyCentAmount, initialTwentyCentAmount, initialTenCentAmount ); _vendingMachineService = new VendingMachineService(_walletFactory); _vendingMachineService.InsertCoinsFromTestInput(deposit.ToWalletDto()); // action var result = _vendingMachineService.BuyProductAsync(productName).Result; // assert Assert.That(result, Is.Not.Null); Assert.That(result.IsSuccess, Is.False); Assert.That(result.Message, Is.EqualTo("Order is cancelled. Sorry, there is no sufficient coin changes.")); Assert.That(result.Wallet, Is.Not.Null); Assert.That(result.Wallet.TotalValue, Is.EqualTo(0)); Assert.That(result.Wallet.OneEuroCoinAmount, Is.EqualTo(expectedOneEuroCoinAmount)); Assert.That(result.Wallet.FiftyCentCoinAmount, Is.EqualTo(expectedFiftyCentCoinAmount)); Assert.That(result.Wallet.TwentyCentCoinAmount, Is.EqualTo(expectedTwentyCentCoinAmount)); Assert.That(result.Wallet.TenCentCoinAmount, Is.EqualTo(expectedTenCentCoinAmount)); }
public MenuManager(ISubMenu subMenu, IVendingMachineService vendingMachineService) { _subMenu = subMenu; _vendingMachineService = vendingMachineService; }
public MachineController(IVendingMachineService vendingMachineService) { _vendingMachineService = vendingMachineService; }
/// <summary> /// /// </summary> /// <param name="service">VendingMachineService</param> public TransactionController(IVendingMachineService service) { this.service = service; }
/// <summary> /// /// </summary> /// <param name="service"></param> public ItemsController(IVendingMachineService service) { this.service = service; }
public VendingMachineController(IVendingMachineService vendingMachineService, UserManager <AppUser> userManager) : base(userManager) { _vendingMachineService = vendingMachineService; }
public VendingMachineController(IVendingMachineService vendingMachineService) { this.vendingMachineService = vendingMachineService; }
public RunApplication() { _vendingMachineService = new VendingMachineService(); }
public void Release(IVendingMachineService vendingMachineService) { CreateVendingMachineServiceService(); }
public void Setup() { _walletFactory = new WalletFactory(); _vendingMachineService = new VendingMachineService(_walletFactory); }
public VendingMachineController(UserManager <User> userManager, IVendingMachineService vendingMachineService) { _userManager = userManager; _vendingMachineService = vendingMachineService; }
public IncomeController(IIncomeService incomeService, IVendingMachineService vendingMachineService, UserManager <AppUser> userManager) : base(userManager) { _incomeService = incomeService; _vendingMachineService = vendingMachineService; }
/// <inheritdoc /> /// <summary> /// Constructor injection of the vending machine service was used here, /// to make the service available to all controller requests /// </summary> /// <param name="vmSvc">Vending machine service instance</param> public VendingMachineController(IVendingMachineService vmSvc) { _vmSvc = vmSvc; }
public DefectController(IDefectService defectService, IVendingMachineService vendingMachineService, UserManager <AppUser> userManager) : base(userManager) { _defectService = defectService; _vendingMachineService = vendingMachineService; }
public VendingMachineController(ILogger <VendingMachineController> logger, IVendingMachineService vendingMachine) { _logger = logger; this.vendingMachine = vendingMachine; }