Exemple #1
0
 public void Apply(AccountOpened @event,bool isReplaying = false)
 {
     _balance = @event.InitialDeposit;
     _id = @event.AccountId;
     Activity.Add("Account Opened On " + @event.On + " with $" + @event.InitialDeposit );
     if (!isReplaying) UncommittedEvents.Add(@event);
 }
        public void lets_do_some_stuff()
        {
            var id = "ihohihoihoihoihoihoijpoawehiohoi";
            var someNewAccountEvent = new AccountOpened
                                          {AccountId = id, InitialDeposit = 1000, On = DateTime.Now};
            var account = new Account(someNewAccountEvent);
            account.Deposit(45);
            account.Withdraw(17);

            _repository.Put(id,account);

            var accountFromRepo = _repository.Get(id);
            Assert.AreEqual(1000 + 45 -17,accountFromRepo._balance);
            //test to make sure we're not applying events multiple times
            _repository.Put(accountFromRepo.Id, accountFromRepo);
        }
 public void create_account()
 {
     var accountOpenedEvent = new AccountOpened {AccountId = "lklhohiohoi", InitialDeposit = 100, On = DateTime.Now};
     var account = new Account(accountOpenedEvent);
     _repository.Put(accountOpenedEvent.AccountId,account);
 }
Exemple #4
0
 public Account(AccountOpened @event)
     : this()
 {
     Apply(@event);
 }