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

            TakeMoneyCommand = new Command<decimal>(x => x > 0, TakeMoney);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
        public void Take_money_raises_an_event()
        {
            Atm atm = new Atm();
            atm.LoadMoney(Dollar);

            atm.TakeMoney(1m);

            atm.ShouldContainBalanceChangedEvent(1.01m);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
 }
예제 #9
0
 public virtual void LoadCashToAtm(Atm atm)
 {
     atm.LoadMoney(Cash);
     Cash = Money.None;
 }