public AtmViewModel(Atm atm)
        {
            _atm = atm;
            _repository = new AtmRepository();
            _paymentGateway = new PaymentGateway();

            TakeMoneyCommand = new Command<decimal>(x => x > 0, TakeMoney);
        }
Exemplo n.º 2
0
        public void Take_money_exchanges_money_with_commission()
        {
            var atm = new Atm();
            atm.LoadMoney(Money.Dollar);

            atm.TakeMoney(1m);

            atm.MoneyCharged.Should().Be(1.01m);
        }
Exemplo n.º 3
0
        public void Commission_is_rounded_up_to_the_next_cent()
        {
            var atm = new Atm();
            atm.LoadMoney(Money.Dollar + Money.TenCent);

            atm.TakeMoney(1.1m);

            atm.MoneyCharged.Should().Be(1.12m);
        }
Exemplo n.º 4
0
        public void Commission_is_at_least_one_cent()
        {
            var atm = new Atm();
            atm.LoadMoney(Money.Cent);

            atm.TakeMoney(0.01m);

            atm.MoneyCharged.Should().Be(0.02m);
        }
Exemplo n.º 5
0
        public void Take_money_raises_an_event()
        {
            Atm atm = new Atm();
            atm.LoadMoney(Dollar);

            atm.TakeMoney(1m);

            atm.ShouldContainBalanceChangedEvent(1.01m);
        }
Exemplo n.º 6
0
        public AtmViewModel(Atm atm, IAtmRepository repository, EventDispatcher eventDispatcher)
        {
            _atm = atm;
            _repository = repository;
            _eventDispatcher = eventDispatcher;
            _paymentGateway = new PaymentGateway();

            TakeMoneyCommand = new Command<decimal>(x => x > 0, TakeMoney);
        }
Exemplo n.º 7
0
        public void Take_money_raises_an_event()
        {
            Initer.Init(@"Server=.\SQLEXPRESS;Database=DddInPractice;Trusted_Connection=true");
            Atm atm = new Atm();
            atm.LoadMoney(Money.Dollar);

            atm.TakeMoney(1m);

            atm.ShouldContainBalanceChangedEvent(1.01m);
        }
Exemplo n.º 8
0
 private static void SetupAtm(IAtmRepository atmRepository)
 {
     var atm = new Atm() {Id = 1};
     atm.LoadMoney(new Money(20,20,20,20,20,20));
     atmRepository.Save(atm);
 }
Exemplo n.º 9
0
 public virtual void LoadCashToAtm(Atm atm)
 {
     atm.LoadMoney(Cash);
     Cash = Money.None;
 }