Пример #1
0
 public SubMenu(IVendingMachineService vendingMachineService, ICampaignService campaignService, IPurchaseService purchaseService, IProductService productService)
 {
     _vendingMachineService = vendingMachineService;
     _campaignService       = campaignService;
     _purchaseService       = purchaseService;
     _productService        = productService;
     //_serviceFactory = serviceFactory;
 }
Пример #2
0
 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;
 }
Пример #4
0
 public static void InsertCoins(
     this IVendingMachineService service,
     CoinType coinType,
     int numberOfCoins
     )
 {
     for (var i = 0; i < numberOfCoins; i++)
     {
         service.InsertCoinAsync(coinType.ToDecimal());
     }
 }
Пример #5
0
        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();
            }
        }
Пример #6
0
 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));
        }
Пример #9
0
 public MenuManager(ISubMenu subMenu, IVendingMachineService vendingMachineService)
 {
     _subMenu = subMenu;
     _vendingMachineService = vendingMachineService;
 }
Пример #10
0
 public MachineController(IVendingMachineService vendingMachineService)
 {
     _vendingMachineService = vendingMachineService;
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="service">VendingMachineService</param>
 public TransactionController(IVendingMachineService service)
 {
     this.service = service;
 }
Пример #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="service"></param>
 public ItemsController(IVendingMachineService service)
 {
     this.service = service;
 }
Пример #13
0
 public VendingMachineController(IVendingMachineService vendingMachineService, UserManager <AppUser> userManager) : base(userManager)
 {
     _vendingMachineService = vendingMachineService;
 }
 public VendingMachineController(IVendingMachineService vendingMachineService)
 {
     this.vendingMachineService = vendingMachineService;
 }
Пример #15
0
 public RunApplication()
 {
     _vendingMachineService = new VendingMachineService();
 }
 public void Release(IVendingMachineService vendingMachineService)
 {
     CreateVendingMachineServiceService();
 }
Пример #17
0
 public void Setup()
 {
     _walletFactory         = new WalletFactory();
     _vendingMachineService = new VendingMachineService(_walletFactory);
 }
Пример #18
0
 public VendingMachineController(UserManager <User> userManager,
                                 IVendingMachineService vendingMachineService)
 {
     _userManager           = userManager;
     _vendingMachineService = vendingMachineService;
 }
Пример #19
0
 public IncomeController(IIncomeService incomeService, IVendingMachineService vendingMachineService, UserManager <AppUser> userManager) : base(userManager)
 {
     _incomeService         = incomeService;
     _vendingMachineService = vendingMachineService;
 }
Пример #20
0
 /// <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;
 }
Пример #21
0
 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;
 }