Ejemplo n.º 1
0
        public void ShouldChangeTheCreditInsideMachine()
        {
            var product = new ProductRepository().GetProduct(1);

            _machineService.AddCredit(new Money(0, 0, 0, 2));

            Assert.DoesNotThrow(() => _machineService.ValidatePurchase(product));
        }
        public void ShouldChangeTheCreditInsideMachine()
        {
            var machineService = new MachineService(new ProductRepository());

            machineService.AddCredit(new Money(1, 0, 0, 0));

            Assert.AreEqual(machineService.Machine.CreditMoney.Total, Money.TenCent.Total);
        }
Ejemplo n.º 3
0
        public void ShouldUpdateMachineMoneyAndReturnMoney()
        {
            var machineService = new MachineService(new ProductRepository());

            machineService.AddCredit(new Money(1, 0, 0, 0));
            machineService.ResetCredit();


            Assert.AreEqual(machineService.Machine.CreditMoney.Total, Money.Zero.Total);
        }
Ejemplo n.º 4
0
        public void ShouldResetTheCreditToZero()
        {
            var machineService = new MachineService(new ProductRepository());

            machineService.AddCredit(new Money(1, 0, 0, 0));
            machineService.CancelPurchase();


            Assert.AreEqual(machineService.Machine.CreditMoney.Total, Money.Zero.Total);
        }
Ejemplo n.º 5
0
        public void ShouldUpdateMachineMoneyAndReturnMoney()
        {
            var product = new ProductRepository().GetProduct(1);

            _machineService.AddCredit(new Money(0, 0, 0, 2));
            var returnMoney = _machineService.Purchase(product);

            Assert.AreEqual(_machineService.Machine.MachineMoney.Total, new Money(100, 99, 99, 102).Total);
            Assert.AreEqual(returnMoney.Total, new Money(0, 1, 1, 0).Total);
        }